Skip to content

Commit

Permalink
Merge pull request #815 from benjwadams/sort_platform_cf_role
Browse files Browse the repository at this point in the history
Sorts accepted cf_role values to allow tests to be consistent
  • Loading branch information
benjwadams authored May 18, 2020
2 parents 56929bd + 1c4161f commit 71a4228
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compliance_checker/ioos.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def check_platform_variable_cf_role(self, ds):
result.msgs[0] = ("Platform variable \"{}\" must have a "
"cf_role attribute with one of the "
"values {}".format(result.variable_name,
valid_cf_roles))
sorted(valid_cf_roles)))

return cf_role_results

Expand Down
10 changes: 5 additions & 5 deletions compliance_checker/tests/test_ioos_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,29 +502,29 @@ def test_check_gts_ingest_requirements(self):
ds.variables["time"].setncattr("standard_name", "time")
result = self.ioos.check_gts_ingest_requirements(ds)
self.assertFalse(result.value)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)

# set ancillary var with bad standard name
tmp = ds.createVariable("tmp", np.byte, ("time",))
tmp.setncattr("standard_name", "bad")
ds.variables["time"].setncattr("ancillary_variables", "tmp")
result = self.ioos.check_gts_ingest_requirements(ds)
self.assertFalse(result.value)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)

# good ancillary var standard name, time units are bad
tmp.setncattr("standard_name", "aggregate_quality_flag")
ds.variables["time"].setncattr("units", "bad since bad")
result = self.ioos.check_gts_ingest_requirements(ds)
self.assertFalse(result.value)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)
self.assertIn('The following variables did not qualify for NDBC/GTS Ingest: time\n', result.msgs)

# good ancillary var stdname, good units, pass
tmp.setncattr("standard_name", "aggregate_quality_flag")
ds.variables["time"].setncattr("units", "seconds since 1970-01-01T00:00:00Z")
result = self.ioos.check_gts_ingest_requirements(ds)
self.assertFalse(result.value)
self.assertIn('The following variables qualified for NDBC/GTS Ingest: time\n', result.msgs)
self.assertIn('The following variables qualified for NDBC/GTS Ingest: time\n', result.msgs)

def test_check_instrument_variables(self):

Expand Down Expand Up @@ -689,7 +689,7 @@ def test_check_platform_cf_role(self):
expected_vals = {"profile_id", "timeseries_id", "trajectory_id"}
expect_msg = (
"Platform variable \"platform\" must have a cf_role attribute "
"with one of the values {}".format(expected_vals))
"with one of the values {}".format(sorted(expected_vals)))
self.assertEqual(results[0].msgs, [expect_msg])
# set to valid value
plat_var.setncattr("cf_role", "timeseries_id")
Expand Down

0 comments on commit 71a4228

Please sign in to comment.