def test_uses_fallback_if_bpm_missing_and_no_bpm_set(mock_get_bpm_filename): image = FakeImageForBPM() fallback_bpm = np.zeros(image.data.shape, dtype=np.uint8) mock_get_bpm_filename.return_value = None tester = BPMUpdater(FakeContextForBPM(no_bpm=True)) assert tester.do_stage(image) is not None np.testing.assert_array_equal(image.bpm, fallback_bpm)
def test_removes_image_wrong_shape_3d(mock_load_bpm, mock_get_bpm_filename, set_random_seed): image = FakeImageForBPM(make_image_3d=True) mock_get_bpm_filename.return_value = 'fake_bpm_filename' mock_load_bpm.return_value = make_test_bpm(image.nx, image.ny) tester = BPMUpdater(FakeContextForBPM()) assert tester.do_stage(image) is None
def test_adds_good_bpm_3d(mock_load_bpm, mock_get_bpm_filename, set_random_seed): image = FakeImageForBPM(make_image_3d=True) bpm_to_load = make_test_bpm(image.nx, image.ny, make_3d=True) mock_get_bpm_filename.return_value = 'fake_bpm_filename' mock_load_bpm.return_value = bpm_to_load tester = BPMUpdater(FakeContextForBPM()) image = tester.do_stage(image) np.testing.assert_array_equal(image.bpm, bpm_to_load) assert image.header.get('L1IDMASK') == 'fake_bpm_filename'
def test_adds_good_bpm(mock_load_bpm, mock_get_bpm_filename, set_random_seed): image = FakeImageForBPM() bpm_to_load = make_test_bpm(image.nx, image.ny) mock_get_bpm_filename.return_value = 'fake_bpm_filename' mock_load_bpm.return_value = bpm_to_load tester = BPMUpdater(FakeContextForBPM()) image = tester.do_stage(image) np.testing.assert_array_equal(image.bpm, bpm_to_load) assert image.header.get('L1IDMASK') == 'fake_bpm_filename'
def test_removes_image_if_file_missing(mock_get_bpm_filename): image = FakeImageForBPM() mock_get_bpm_filename.return_value = None tester = BPMUpdater(FakeContextForBPM()) assert tester.do_stage(image) is None
def test_null_input_imags(): tester = BPMUpdater(None) image = tester.run(None) assert image is None