Skip to content

Commit cef7c03

Browse files
committed
Add tests for mkdocs
1 parent 390b234 commit cef7c03

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

readthedocs/rtd_tests/tests/test_config_integration.py

+75
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,78 @@ def test_sphinx_fail_on_warning(
678678
assert '-W' in args
679679
append_conf.assert_called_once()
680680
move.assert_called_once()
681+
682+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.move')
683+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.append_conf')
684+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.run')
685+
def test_mkdocs_configuration(
686+
self, run, append_conf, move, checkout_path, tmpdir):
687+
checkout_path.return_value = str(tmpdir)
688+
apply_fs(tmpdir, {
689+
'mkdocs.yml': '',
690+
'docx': {
691+
'mkdocs.yml': '',
692+
},
693+
})
694+
self.create_config_file(
695+
tmpdir,
696+
{
697+
'mkdocs': {
698+
'configuration': 'docx/mkdocs.yml',
699+
},
700+
}
701+
)
702+
703+
update_docs = self.get_update_docs_task()
704+
config = update_docs.config
705+
python_env = Virtualenv(
706+
version=self.version,
707+
build_env=update_docs.build_env,
708+
config=config
709+
)
710+
update_docs.python_env = python_env
711+
712+
update_docs.build_docs_html()
713+
714+
args, kwargs = run.call_args
715+
assert '--config-file' in args
716+
assert path.join(str(tmpdir), 'docx/mkdocs.yml') in args
717+
append_conf.assert_called_once()
718+
move.assert_called_once()
719+
720+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.move')
721+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.append_conf')
722+
@patch('readthedocs.doc_builder.backends.mkdocs.BaseMkdocs.run')
723+
def test_mkdocs_fail_on_warning(
724+
self, run, append_conf, move, checkout_path, tmpdir):
725+
checkout_path.return_value = str(tmpdir)
726+
apply_fs(tmpdir, {
727+
'docx': {
728+
'mkdocs.yml': '',
729+
},
730+
})
731+
self.create_config_file(
732+
tmpdir,
733+
{
734+
'mkdocs': {
735+
'configuration': 'docx/mkdocs.yml',
736+
'fail_on_warning': True,
737+
},
738+
}
739+
)
740+
741+
update_docs = self.get_update_docs_task()
742+
config = update_docs.config
743+
python_env = Virtualenv(
744+
version=self.version,
745+
build_env=update_docs.build_env,
746+
config=config
747+
)
748+
update_docs.python_env = python_env
749+
750+
update_docs.build_docs_html()
751+
752+
args, kwargs = run.call_args
753+
assert '--strict' in args
754+
append_conf.assert_called_once()
755+
move.assert_called_once()

0 commit comments

Comments
 (0)