def test__run_disk_test_raises_ExportError_if_not_USB_ENCRYPTED(mocker): """ Ensure ExportError is raised if _run_disk_test returns anything other than 'USB_ENCRYPTED'. """ export = Export() export._create_archive = mocker.MagicMock(return_value="mock_archive_path") export._export_archive = mocker.MagicMock( return_value="SOMETHING_OTHER_THAN_USB_ENCRYPTED") with pytest.raises(ExportError): export._run_disk_test("mock_archive_dir")
def test__run_disk_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_ENCRYPTED' is the ouput status of _export_archive. """ export = Export() export._create_archive = mocker.MagicMock(return_value="mock_archive_path") export._export_archive = mocker.MagicMock(return_value="USB_ENCRYPTED") export._run_disk_test("mock_archive_dir") export._export_archive.assert_called_once_with("mock_archive_path") export._create_archive.assert_called_once_with("mock_archive_dir", "disk-test.sd-export", {"device": "disk-test"})
def test__run_disk_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_ENCRYPTED' is the ouput status of _export_archive. ''' export = Export() export._create_archive = mocker.MagicMock(return_value='mock_archive_path') export._export_archive = mocker.MagicMock(return_value='USB_ENCRYPTED') export._run_disk_test('mock_archive_dir') export._export_archive.assert_called_once_with('mock_archive_path') export._create_archive.assert_called_once_with('mock_archive_dir', 'disk-test.sd-export', {'device': 'disk-test'})