def test_create_robotdocs(mock_run, mock_robotdocsrst,
                          mock_search_for_robotdocsconf, runresult):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0), runresult]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    dc = DocCreator(robotdocs_root_folders='robotdocs', run=mock_run)
    dc.create_robotdocs()

    assert mock_run.mock_calls[0] == mock.call(robotdoc_generation_call)
    assert mock_run.mock_calls[1] == mock.call(robotdoc_kwd_list_call)
    assert mock_robotdocsrst.content == robotdocs_rst_expected_content()
Example #2
0
def test_create_no_sphinxdocs(mock_run,
                              mock_search_for_robotdocsconf):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0)]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()

    mock_run.assert_called_once_with(robotdoc_generation_call)
Example #3
0
def test_create_outputfile_included(mock_run,
                                    mock_module1rst,
                                    mock_search_for_robotdocsconf):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0),
                            runresult_robotlib_kwd_list_2kwds,
                            RunResult(sphinxdocs_generation_call, 0)]
    mock_search_for_robotdocsconf.return_value = ['folder2']
    DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()
    assert mock_module1rst.content == robotdocs_rst_expected_content()
def test_create_generate_robotdocs_rst_synopsis(mock_run, mock_robotdocsrst,
                                                mock_search_for_robotdocsconf):
    mock_search_for_robotdocsconf.return_value = ['folder1']
    mock_run.side_effect = [
        RunResult(robotdoc_generation_call, 0),
        runresult_robotlib_kwd_list_2kwds,
        RunResult(sphinxdocs_generation_call, 0)
    ]
    DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()
    assert mock_robotdocsrst.content == robotdocs_rst_expected_content(
        library_sections=[robotdocs_rst_library_section(synopsis='synopsis')])
Example #5
0
def test_create_with_robotdocs_but_no_html_extra_path(
        mock_run,
        mock_search_for_robotdocsconf):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0),
                            runresult_robotlib_kwd_list_2kwds]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    with pytest.raises(FailedToCreateDocs) as excinfo:
        DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()

    message = "Incorrect configuration found in {sphinx_conf}"
    message = message.format(sphinx_conf=os.path.join('sphinxdocs', 'conf.py'))
    assert message in str(excinfo.value)
Example #6
0
def test_create_one_robotdocsconf(mock_run,
                                  mock_robotdocsrst,
                                  mock_search_for_robotdocsconf):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0),
                            runresult_robotlib_kwd_list_2kwds,
                            RunResult(sphinxdocs_generation_call, 0)]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()
    assert mock_robotdocsrst.content == robotdocs_rst_expected_content()
    assert mock_run.mock_calls[0] == mock.call(robotdoc_generation_call)
    assert mock_run.mock_calls[1] == mock.call(robotdoc_kwd_list_call)
    assert mock_run.mock_calls[2] == mock.call(sphinxdocs_generation_call)
def test_create_multiargs(mock_run, mock_search_for_robotdocsconf):
    mock_run.side_effect = [
        RunResult(robotdoc_generation_call, 0),
        runresult_robotlib_kwd_list_2kwds,
        RunResult(sphinxdocs_generation_call, 0)
    ]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    DocCreator(robotdocs_root_folders='folder1', run=mock_run).create()

    assert (mock_run.mock_calls[0] == mock.call(
        'python'
        ' -m robot.libdoc'
        ' -f html'
        ' -F docformat'
        ' library::arg1::arg2'
        ' {}'.format(os.path.join('robotdocs', 'library.html'))))
Example #8
0
def test_create_from_resource_file(mock_run,
                                   mock_robotdocsrst,
                                   mock_search_for_robotdocsconf):
    mock_run.side_effect = [RunResult(robotdoc_generation_call, 0),
                            runresult_robotlib_kwd_list_2kwds,
                            RunResult(sphinxdocs_generation_call, 0)]
    mock_search_for_robotdocsconf.return_value = ['folder1']
    DocCreator(robotdocs_root_folders='folder1', run=mock_run).create()

    assert (mock_run.mock_calls[0] ==
            mock.call('python'
                      ' -m robot.libdoc'
                      ' -f html'
                      ' -F robot'
                      ' resources/subfolder1/subfolder2/resource_file.robot'
                      ' {}'.format(
                          os.path.join('robotdocs',
                                       'resource_file.robot.html'))))

    assert (mock_robotdocsrst.content == robotdocs_rst_expected_content(
        library_sections=[robotdocs_rst_library_section(
            libname='resources/subfolder1/subfolder2/resource_file.robot')]))
def test_create_without_robotdocs(mock_run):
    mock_run.side_effect = [RunResult(sphinxdocs_generation_call, 0)]
    DocCreator(robotdocs_root_folders='robotdocs', run=mock_run).create()
    mock_run.assert_called_with(sphinxdocs_generation_call)
Example #10
0
 def _generate_robotdocs(self, runner):
     if not self.packagehandler.novirtualenv:
         self._install_docs_requirements(runner)
     DocCreator(robotdocs_root_folders='robotdocs',
                run=runner.run).create_robotdocs()