Repository: ioos/compliance-checker
Pull request #815 (2020-05-18 19:20:38)

Sorts accepted cf_role values to allow tests to be consistent


Patch:
diff --git a/compliance_checker/ioos.py b/compliance_checker/ioos.py
index c76f080..bab45bf 100644
--- a/compliance_checker/ioos.py
+++ b/compliance_checker/ioos.py
@@ -824,7 +824,7 @@ class IOOS1_2Check(IOOSNCCheck):
                 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
 


Test patch:
diff --git a/compliance_checker/tests/test_ioos_profile.py b/compliance_checker/tests/test_ioos_profile.py
index 1c77531..8b76710 100644
--- a/compliance_checker/tests/test_ioos_profile.py
+++ b/compliance_checker/tests/test_ioos_profile.py
@@ -502,7 +502,7 @@ class TestIOOS1_2(BaseTestCase):
         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",))
@@ -510,21 +510,21 @@ class TestIOOS1_2(BaseTestCase):
         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):
 
@@ -689,7 +689,7 @@ class TestIOOS1_2(BaseTestCase):
         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")