Exemplo n.º 1
0
 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)
                               )
                     )
Exemplo n.º 2
0
 def test_function_calculate_batches_for_masks(self, mock_view_as_win):
     """
     Test that self.mask_batches aand self.mask_batches_amsr2 are correctly created by correct
     call of view_as_windows function
     """
     test_archive = Archive()
     test_archive.final_ful_mask = 1
     test_archive.WINDOW_SIZE = (2, 2)
     test_archive.STRIDE_SAR_SIZE = 3
     test_archive.final_mask_with_amsr2_size = 4
     test_archive.WINDOW_SIZE_AMSR2 = (5, 5)
     test_archive.STRIDE_AMS2_SIZE = 6
     test_archive.calculate_batches_for_masks()
     self.assertEqual(mock_view_as_win.call_args_list[0], mock.call(1, (2, 2), 3))
     self.assertEqual(mock_view_as_win.call_args_list[1], mock.call(4, (5, 5), 6))