-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement sphinx key from v2 config #4482
Merged
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f7dc3bd
Test conf.py default value
stsewd 09ea0dc
Fix conf.py path
stsewd 0648f65
Don't skip tests
stsewd e9db42c
Expose config object in builders
stsewd 7fe49ee
Use doctype from config
stsewd 954e277
Pass python_env in tests
stsewd 292f912
Fix old test
stsewd 19810f4
Implement sphinx key
stsewd fb48f7c
Implement fail_on_warning
stsewd 1083999
Skip tests for mkdocs
stsewd d35c23c
Fix raising wrong exception
stsewd 58adc35
Fix tests
stsewd 819a9fa
Remove search from tests
stsewd e6b9dd5
Return the absolute path
stsewd db40aa7
Check for None
stsewd b4c22dd
Use the config file
stsewd 6ee2d66
Fix test
stsewd 4750efd
Merge branch 'master' into build-config-v2-phinx
stsewd aa25732
Fix test
stsewd 189726c
Remove repetition
stsewd dc99eb8
Break and fix test
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,7 +232,6 @@ def test_requirements_file(self, load_config): | |
self.assertEqual(config.python.requirements, '__init__.py') | ||
|
||
|
||
@pytest.mark.skip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests are un-skipped here |
||
@pytest.mark.django_db | ||
@mock.patch('readthedocs.projects.models.Project.checkout_path') | ||
class TestLoadConfigV2(object): | ||
|
@@ -290,12 +289,10 @@ def test_report_using_invalid_version(self, checkout_path, tmpdir): | |
|
||
@pytest.mark.parametrize('config', [{}, {'formats': []}]) | ||
@patch('readthedocs.projects.models.Project.repo_nonblockinglock', new=MagicMock()) | ||
@patch('readthedocs.doc_builder.backends.sphinx.SearchBuilder.build') | ||
@patch('readthedocs.doc_builder.backends.sphinx.HtmlBuilder.build') | ||
@patch('readthedocs.doc_builder.backends.sphinx.HtmlBuilder.append_conf') | ||
def test_build_formats_default_empty( | ||
self, append_conf, html_build, search_build, | ||
checkout_path, config, tmpdir): | ||
self, append_conf, html_build, checkout_path, config, tmpdir): | ||
""" | ||
The default value for formats is [], which means no extra | ||
formats are build. | ||
|
@@ -304,22 +301,26 @@ def test_build_formats_default_empty( | |
self.create_config_file(tmpdir, config) | ||
|
||
update_docs = self.get_update_docs_task() | ||
python_env = Virtualenv( | ||
version=self.version, | ||
build_env=update_docs.build_env, | ||
config=config | ||
) | ||
update_docs.python_env = python_env | ||
outcomes = update_docs.build_docs() | ||
|
||
# No extra formats were triggered | ||
assert outcomes['html'] | ||
assert outcomes['search'] | ||
assert not outcomes['localmedia'] | ||
assert not outcomes['pdf'] | ||
assert not outcomes['epub'] | ||
|
||
@patch('readthedocs.projects.models.Project.repo_nonblockinglock', new=MagicMock()) | ||
@patch('readthedocs.projects.tasks.UpdateDocsTaskStep.build_docs_class') | ||
@patch('readthedocs.doc_builder.backends.sphinx.SearchBuilder.build') | ||
@patch('readthedocs.doc_builder.backends.sphinx.HtmlBuilder.build') | ||
@patch('readthedocs.doc_builder.backends.sphinx.HtmlBuilder.append_conf') | ||
def test_build_formats_only_pdf( | ||
self, append_conf, html_build, search_build, build_docs_class, | ||
self, append_conf, html_build, build_docs_class, | ||
checkout_path, tmpdir): | ||
""" | ||
Only the pdf format is build. | ||
|
@@ -328,11 +329,17 @@ def test_build_formats_only_pdf( | |
self.create_config_file(tmpdir, {'formats': ['pdf']}) | ||
|
||
update_docs = self.get_update_docs_task() | ||
python_env = Virtualenv( | ||
version=self.version, | ||
build_env=update_docs.build_env, | ||
config=update_docs.config | ||
) | ||
update_docs.python_env = python_env | ||
|
||
outcomes = update_docs.build_docs() | ||
|
||
# Only pdf extra format was triggered | ||
assert outcomes['html'] | ||
assert outcomes['search'] | ||
build_docs_class.assert_called_with('sphinx_pdf') | ||
assert outcomes['pdf'] | ||
assert not outcomes['localmedia'] | ||
|
@@ -642,6 +649,35 @@ def test_sphinx_configuration_default( | |
append_conf.assert_called_once() | ||
move.assert_called_once() | ||
|
||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.move') | ||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.append_conf') | ||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.run') | ||
def test_sphinx_configuration_default( | ||
self, run, append_conf, move, checkout_path, tmpdir): | ||
"""Should be default to find a conf.py file.""" | ||
checkout_path.return_value = str(tmpdir) | ||
|
||
apply_fs(tmpdir, {'conf.py': ''}) | ||
self.create_config_file(tmpdir, {}) | ||
self.project.conf_py_file = '' | ||
self.project.save() | ||
|
||
update_docs = self.get_update_docs_task() | ||
config = update_docs.config | ||
python_env = Virtualenv( | ||
version=self.version, | ||
build_env=update_docs.build_env, | ||
config=config | ||
) | ||
update_docs.python_env = python_env | ||
|
||
update_docs.build_docs_html() | ||
|
||
args, kwargs = run.call_args | ||
assert kwargs['cwd'] == str(tmpdir) | ||
append_conf.assert_called_once() | ||
move.assert_called_once() | ||
|
||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.move') | ||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.append_conf') | ||
@patch('readthedocs.doc_builder.backends.sphinx.BaseSphinx.run') | ||
|
@@ -716,6 +752,7 @@ def test_sphinx_fail_on_warning( | |
append_conf.assert_called_once() | ||
move.assert_called_once() | ||
|
||
@pytest.mark.skip | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.move') | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.append_conf') | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.run') | ||
|
@@ -754,6 +791,7 @@ def test_mkdocs_configuration( | |
append_conf.assert_called_once() | ||
move.assert_called_once() | ||
|
||
@pytest.mark.skip | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.move') | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.append_conf') | ||
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.run') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me why this change is needed. Shouldn't the full path have already been returned by
version.get_conf_py_path()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was bitten by the name here too, this only returns the directory name. There is a test unskipped that covers this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh. is there a reason why this was working then? It seems like it shouldn't have worked at all if it was just the directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't have a test, but I added them in https://github.com/rtfd/readthedocs.org/pull/4456/files#diff-5a2cc4147895068b33fe5bf89e4e6e08R589 (skipped)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also currently we are reading this from the database, that's why the builds don't fail