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_check_file_healthiness_2(self): """test unhealthiness because of missing AMSR file""" test_archive = Archive() test_archive.RM_SWATH = 0 test_archive.WINDOW_SIZE = (50, 50) # the second case of unhealthy file fil = mock.Mock(variables=['polygon_icechart']) test_archive.AMSR_LABELS = ["btemp_6.9h"] self.assertFalse(test_archive.check_file_healthiness(fil, "fake_name"))
def test_function_check_file_healthiness_4(self): """test healthiness file for a healthy file""" test_archive = Archive() test_archive.RM_SWATH = 0 test_archive.WINDOW_SIZE = (50, 50) test_archive.AMSR_LABELS = ["btemp_6.9h"] # file is healthy fil = mock.Mock(variables=['polygon_icechart', 'btemp_6.9h'], aoi_upperleft_sample=3, aoi_lowerright_sample=120, aoi_lowerright_line=200, aoi_upperleft_line=14, ) self.assertTrue(test_archive.check_file_healthiness(fil, "fake_name"))
def test_function_check_file_healthiness_3(self): """test unhealthiness because of small data window size""" test_archive = Archive() test_archive.RM_SWATH = 0 test_archive.WINDOW_SIZE = (50, 50) test_archive.AMSR_LABELS = ["btemp_6.9h"] # the third case of unhealthy file fil = mock.Mock(variables=['polygon_icechart', 'btemp_6.9h'], aoi_upperleft_sample=3, aoi_lowerright_sample=12, aoi_lowerright_line=2, aoi_upperleft_line=14, ) self.assertFalse(test_archive.check_file_healthiness(fil, "fake_name"))