Esempio n. 1
0
def test_get_additional_info_opens_dialog_box(monkeypatch):
    workflow = workflow_hathiprep.HathiPrepWorkflow()
    user_args = {
        "input": "./some_real_source_folder",
        "Image File Type": "JPEG 2000",
    }

    def mock_scandir(path):
        for i_number in range(20):
            file_mock = Mock()
            file_mock.is_dir = Mock(return_value=True)
            file_mock.name = f"99423682912205899-{str(i_number).zfill(8)}"
            yield file_mock

    from speedwagon.workflows.title_page_selection import PackageBrowser
    package_browser = Mock()
    package_browser.result = Mock(return_value=PackageBrowser.Accepted)
    package_browser.Accepted = PackageBrowser.Accepted

    def mock_package_browser(_, __):
        return package_browser

    with monkeypatch.context() as mp:
        mp.setattr(os, "scandir", mock_scandir)
        mp.setattr(workflow_hathiprep, "PackageBrowser", mock_package_browser)

        extra_info = workflow.get_additional_info(None,
                                                  options=user_args,
                                                  pretask_results=[])
    assert package_browser.exec.called is True and \
           "packages" in extra_info
Esempio n. 2
0
def test_initial_task_creates_task():
    workflow = workflow_hathiprep.HathiPrepWorkflow()
    user_args = {
        "input": "./some_real_source_folder",
        "Image File Type": "JPEG 2000",
    }

    mock_builder = Mock()
    workflow.initial_task(task_builder=mock_builder, **user_args)
    assert \
        mock_builder.add_subtask.called is True and \
        mock_builder.add_subtask.call_args_list[0][0][0]._root == user_args['input']
Esempio n. 3
0
def unconfigured_workflow():
    workflow = workflow_hathiprep.HathiPrepWorkflow()
    user_options = {i.label_text: i.data for i in workflow.user_options()}

    return workflow, user_options
Esempio n. 4
0
def test_workflow_options(index, label):
    workflow = workflow_hathiprep.HathiPrepWorkflow()
    user_options = workflow.user_options()
    assert len(user_options) > 0
    assert user_options[index].label_text == label