def test_should_only_get_specific_indices(self): """ If we only give n indices, we should get n data points back :return: Nothing """ print("Testing that get_region returns correct amount of data") test_many = get_region_data(self.wmo_boxes, self.float_name, self.config, self.index, self.pres) self.assertTrue(test_many['grid_sal'].shape[1] == self.index.__len__()) test_one = get_region_data(self.wmo_boxes, self.float_name, self.config, [50], self.pres) self.assertTrue(test_one['grid_sal'].shape[1] == 1)
def test_return_shape(self): """ check that the 6 arrays are the expected shape :return: Nothing """ print( "Testing that get_region_data return values are the correct shape") test = get_region_data(self.wmo_boxes, self.float_name, self.config, self.index, self.pres) self.assertTrue( test['grid_sal'].shape == test['grid_ptmp'].shape == test['grid_pres'].shape, "salinity, pressure, and potential temperature " "arrays should be same shape") self.assertTrue( test['grid_lat'].shape == test['grid_long'].shape == test['grid_dates'].shape, "longitude, latitude, and date arrays should be the same shape") self.assertTrue( test['grid_sal'].shape[1] == test['grid_ptmp'].shape[1] == test['grid_pres'].shape[1] == test['grid_lat'].shape[0] == test['grid_long'].shape[0] == test['grid_dates'].shape[0] == self.index.__len__(), "Should get the same number of casts as we have asked for")
def test_raise_exception_bad_indices(self): """ Check that, if only bad indices are given, an exception is raised :return: Nothing """ print("Testing exception is raised if indices are bad") with self.assertRaises(Exception) as no_index: get_region_data(self.wmo_boxes, self.float_name, self.config, [], self.pres) self.assertTrue('NO DATA FOUND' in str(no_index.exception)) with self.assertRaises(Exception) as big_index: get_region_data(self.wmo_boxes, self.float_name, self.config, [99999999999999999], self.pres) self.assertTrue('NO DATA FOUND' in str(big_index.exception))
def test_returns_6(self): """ check that the function returns 6 arrays :return: Nothing """ print("Testing that get_region_data returns 6 arrays") test = get_region_data(self.wmo_boxes, self.float_name, self.config, self.index, self.pres) self.assertTrue(test.__len__() == 6, "Should return 6 arrays")
def test_gets_different_data(self): """ Check that we can fetch different combinations of data :return: Nothing """ print("Testing that get_region_data can return different data types") test_ctd = get_region_data( np.array([[self.config['TEST_FLOAT_WMO_BOXES'][0], 1, 0, 0]]), self.float_name, self.config, self.index, self.pres) test_bot = get_region_data( np.array([[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 1, 0]]), self.float_name, self.config, self.index, self.pres) test_argo = get_region_data( np.array([[self.config['TEST_FLOAT_WMO_BOXES'][0], 0, 0, 1]]), self.float_name, self.config, self.index, self.pres) self.assertTrue( test_ctd['grid_sal'].shape[1] != test_argo['grid_sal'].shape[1], "Should get a different data set, if we have specified it") self.assertTrue( test_bot['grid_sal'].shape[1] != test_argo['grid_sal'].shape[1], "Should get a different data set, if we have specified it")