From e99cbe85c44c83fe41a39d55178839683088ba34 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Wed, 28 Aug 2024 22:22:48 +0000 Subject: [PATCH] fix bug on experimental/bare topics --- pywis_topics/topics.py | 2 +- tests/run_tests.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pywis_topics/topics.py b/pywis_topics/topics.py index 5ee3ed0..18b589c 100644 --- a/pywis_topics/topics.py +++ b/pywis_topics/topics.py @@ -211,7 +211,7 @@ def _validate_esd_subtopic(self, esd_subtopic: str, if strict: LOGGER.debug('Validating subtopic with strict mode') - is_experimental = esd_subtopic.split('/')[1] == 'experimental' + is_experimental = '/experimental' in esd_subtopic return esd_subtopic in self.topics[-1] or is_experimental tokens = esd_subtopic.split('/') diff --git a/tests/run_tests.py b/tests/run_tests.py index 58df03b..2610e5c 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -137,6 +137,12 @@ def test_validate(self): value = 'cache/a/wis2/ca-eccc-msc/data/core/weather/experimental/surface-based-observations' # noqa self.assertTrue(self.th.validate(value)) + value = 'origin/a/wis2/ca-eccc-msc/data/core/ocean' # noqa + self.assertTrue(self.th.validate(value)) + + value = 'cache/a/wis2/ca-eccc-msc/data/core/ocean' # noqa + self.assertTrue(self.th.validate(value)) + value = 'cache/a/wis2/ca-eccc-msc/data/core/weather/surface-based-observations/#' # noqa self.assertTrue(self.th.validate(value, strict=False)) self.assertFalse(self.th.validate(value))