コード例 #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)
                               )
                     )
コード例 #2
0
 def test_function_get_unprocessed_files(self):
     """ Without having a file named 'processed_files.json' in the output folder,
     'files' attribute must be filled with what comes out of litsdir of input folder. """
     test_archive = Archive()
     test_archive.OUTPATH = ""
     with mock.patch("os.listdir", return_value=["a.nc"]):
         test_archive.get_unprocessed_files()
     self.assertEqual(test_archive.files, ['a.nc'])
     self.assertEqual(test_archive.processed_files, [])
コード例 #3
0
 def test_function_update_processed_files(self):
     """processed_files attribute must be updated based on the content of 'files' and calling the
     function 'update_processed_files'."""
     test_archive = Archive()
     test_archive.processed_files = []
     test_archive.files = ["0.nc","1.nc","2.nc","3.nc"]
     temp_fold = tempfile.TemporaryDirectory()
     test_archive.OUTPATH = temp_fold.name
     test_archive.update_processed_files(1)
     test_archive.update_processed_files(3)
     self.assertEqual(test_archive.processed_files, ["1.nc", "3.nc"])