def test_function_write_batches(self, mock_savez): """Test writing the correct content with a correct filename into npz files""" test_archive = Archive() test_archive.scene = "20180410T084537" test_archive.OUTPATH = "/etc" test_archive.NERSC = "nersc_" test_archive.final_ful_mask = None test_archive.final_mask_with_amsr2_size = None test_archive.SAR_NAMES = ['sar'] test_archive.AMSR_LABELS = ['btemp_6.9h'] test_archive.names_polygon_codes = ['id', 'CT'] test_archive.PROP = {'sar': [7, 8, 9], 'btemp_6_9h': [4, 5, 6], 'CT': [1, 2, 3], '_locs': [(11, 12), (13, 14), (15, 16)]} test_archive.write_batches() self.assertEqual(mock_savez.call_args_list[0], mock.call('/etc/20180410T084537_000000_nersc_-11_12', sar=7, btemp_6_9h=4, CT=1, _locs=(11, 12) ) ) self.assertEqual(mock_savez.call_args_list[1], mock.call('/etc/20180410T084537_000001_nersc_-13_14', sar=8, btemp_6_9h=5, CT=2, _locs=(13, 14) ) ) self.assertEqual(mock_savez.call_args_list[2], mock.call('/etc/20180410T084537_000002_nersc_-15_16', sar=9, btemp_6_9h=6, CT=3, _locs=(15, 16) ) )
def test_function_process_dataset(self, mock_variable_ML, mock_pad_and_batch, mock_batches_for_masks, mock_calculate_mask, mock_read, mock_check, mock_view_as_win, mock_init_Archive, mock_init_Output_ba, mock_init_Sar_ba, mock_init_Amsr2_ba): """Test that the functions are called correctly and the PROP is correctly updated""" fil = mock.Mock() filename = mock.Mock() test_archive = Archive() test_archive.PROP = {} test_archive.mask_batches_amsr2 = None test_archive.mask_batches = None test_archive.process_dataset(fil, filename) # PROP must be assembled version of output of function # which is created stepwisely with side effect self.assertEqual(test_archive.PROP, {1: 1, 2: 2, 3: 3}) mock_check.assert_called_once() mock_read.assert_called_once() mock_calculate_mask.assert_called_once() mock_batches_for_masks.assert_called_once() mock_pad_and_batch.assert_called() mock_init_Output_ba.assert_called_once() mock_init_Sar_ba.assert_called_once() mock_init_Amsr2_ba.assert_called_once()