예제 #1
0
def test__run_print_raises_ExportError_if_not_empty_string(mocker):
    """
    Ensure ExportError is raised if _run_print returns anything other than ''.
    """
    export = Export()
    export._create_archive = mocker.MagicMock(return_value="mock_archive_path")
    export._export_archive = mocker.MagicMock(
        return_value="SOMETHING_OTHER_THAN_EMPTY_STRING")

    with pytest.raises(ExportError):
        export._run_print("mock_archive_dir", ["mock_filepath"])
예제 #2
0
def test__run_print_raises_ExportError_if_not_empty_string(mocker):
    '''
    Ensure ExportError is raised if _run_print returns anything other than ''.
    '''
    export = Export()
    export._create_archive = mocker.MagicMock(return_value='mock_archive_path')
    export._export_archive = mocker.MagicMock(
        return_value='SOMETHING_OTHER_THAN_EMPTY_STRING')

    with pytest.raises(ExportError):
        export._run_print('mock_archive_dir', ['mock_filepath'])
예제 #3
0
def test__run_print(mocker):
    """
    Ensure _export_archive and _create_archive are called with the expected parameters and
    _export_archive is called with the return value of _create_archive.
    """
    export = Export()
    export._create_archive = mocker.MagicMock(return_value="mock_archive_path")
    export._export_archive = mocker.MagicMock(return_value="")

    export._run_print("mock_archive_dir", ["mock_filepath"])

    export._export_archive.assert_called_once_with("mock_archive_path")
    export._create_archive.assert_called_once_with("mock_archive_dir",
                                                   "print_archive.sd-export",
                                                   {"device": "printer"},
                                                   ["mock_filepath"])
예제 #4
0
def test__run_print(mocker):
    '''
    Ensure _export_archive and _create_archive are called with the expected parameters and
    _export_archive is called with the return value of _create_archive.
    '''
    export = Export()
    export._create_archive = mocker.MagicMock(return_value='mock_archive_path')
    export._export_archive = mocker.MagicMock(return_value='')

    export._run_print('mock_archive_dir', ['mock_filepath'])

    export._export_archive.assert_called_once_with('mock_archive_path')
    export._create_archive.assert_called_once_with('mock_archive_dir',
                                                   'print_archive.sd-export', {
                                                       'device': 'printer',
                                                   }, ['mock_filepath'])