def test_GIVEN_valid_file_w_1_var_same_shape_others_not_and_t_is_multid_WHEN_get_vars_THEN_only_same_shape_returned( self): time_dims = ["Time", "time2"] time_var = "time_var" expected_var = "good_shape" variable_dimensions = { time_var: time_dims, expected_var: time_dims, "too_many_dims": ["one", "two", "Three"], "too_few_dims": ["one"], "Not time": ["not time", "not Time"], "Time and one other": [time_dims[0], time_dims[1], "other"], "Time and Time": [time_dims[0], time_dims[0]], "Time2 and time": [time_dims[1], time_dims[0]] } attributes = {"Time_Coordinate": time_var, "Station_Lat": "27.1", "Station_Lon": "10"} variables = [{key: self.MockVar(val) for key, val in variable_dimensions.items()}] decider = NCAR_NetCDF_RAF_variable_name_selector(attributes, variables) vars = decider.get_variable_names_with_same_dimensions_as_time_coord() assert_that(vars, is_(set([expected_var, time_var])), "variables should be ones with same dim as time")
def test_GIVEN_valid_file_with_all_variables_same_shape_as_time_WHEN_get_vars_THEN_all_variables_returned(self): expected_time_var = "time_var" expected_station_latitude = "27.1" expected_station_longitude = "10" variables = [{expected_time_var: self.MockVar(), "another_var": self.MockVar()}] attributes = {"Time_Coordinate": expected_time_var, "Station_Lat": expected_station_latitude, "Station_Lon": expected_station_longitude} aggregated_dim = "Time" expected_time_dimensions = [aggregated_dim] decider = NCAR_NetCDF_RAF_variable_name_selector(attributes, variables) vars = decider.get_variable_names_with_same_dimensions_as_time_coord() assert_that(vars, all(variables), "File should be for station")