Ejemplo n.º 1
0
def test__run_usb_test_raises_ExportError_if_not_USB_CONNECTED(mocker):
    """
    Ensure ExportError is raised if _run_disk_test returns anything other than 'USB_CONNECTED'.
    """
    export = Export()
    export._create_archive = mocker.MagicMock(return_value="mock_archive_path")
    export._export_archive = mocker.MagicMock(
        return_value="SOMETHING_OTHER_THAN_USB_CONNECTED")

    with pytest.raises(ExportError):
        export._run_usb_test("mock_archive_dir")
Ejemplo n.º 2
0
def test__run_usb_test(mocker):
    """
    Ensure _export_archive and _create_archive are called with the expected parameters,
    _export_archive is called with the return value of _create_archive, and
    _run_disk_test returns without error if 'USB_CONNECTED' is the return value of _export_archive.
    """
    export = Export()
    export._create_archive = mocker.MagicMock(return_value="mock_archive_path")
    export._export_archive = mocker.MagicMock(return_value="USB_CONNECTED")

    export._run_usb_test("mock_archive_dir")

    export._export_archive.assert_called_once_with("mock_archive_path")
    export._create_archive.assert_called_once_with("mock_archive_dir",
                                                   "usb-test.sd-export",
                                                   {"device": "usb-test"})
Ejemplo n.º 3
0
def test__run_usb_test(mocker):
    '''
    Ensure _export_archive and _create_archive are called with the expected parameters,
    _export_archive is called with the return value of _create_archive, and
    _run_disk_test returns without error if 'USB_CONNECTED' is the return value of _export_archive.
    '''
    export = Export()
    export._create_archive = mocker.MagicMock(return_value='mock_archive_path')
    export._export_archive = mocker.MagicMock(return_value='USB_CONNECTED')

    export._run_usb_test('mock_archive_dir')

    export._export_archive.assert_called_once_with('mock_archive_path')
    export._create_archive.assert_called_once_with('mock_archive_dir',
                                                   'usb-test.sd-export',
                                                   {'device': 'usb-test'})