Skip to content

Commit 185246b

Browse files
committed
Pub/Sub links: distinguish bad channel based on centre-id
1 parent b1a20b5 commit 185246b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pywcmp/wcmp2/ets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,20 @@ def test_requirement_links(self):
499499
status['message'] = f"invalid link relation {link['rel']}"
500500
return status
501501

502-
LOGGER.debug('Checking that Pub/Sub links have a channel')
502+
LOGGER.debug('Checking that Pub/Sub links have a valid channel')
503503
if link['href'].startswith('mqtt'):
504504
if 'channel' not in link:
505505
status['code'] = 'FAILED'
506506
status['message'] = 'missing channel for Pub/Sub link'
507507
return status
508508

509509
if link['channel'].startswith(('origin/a/wis2', 'cache/a/wis2')): # noqa
510+
centre_id = link['channel'].split('/')[3]
511+
if centre_id not in self.th.topics[3]:
512+
status['code'] = 'FAILED'
513+
status['message'] = 'Invalid WIS2 topic (bad centre-id) for Pub/Sub link channel' # noqa
514+
return status
515+
510516
LOGGER.debug('Validating topic in link channel')
511517
if not self.th.validate(link['channel']):
512518
status['code'] = 'FAILED'

tests/run_tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,23 @@ def test_fail_invalid_geometry_range(self):
234234
self.assertEqual(codes.count('PASSED'), 11)
235235
self.assertEqual(codes.count('SKIPPED'), 0)
236236

237+
def test_fail_invalid_link_channel_centre_id(self):
238+
"""
239+
Simple tests for a failing record with an invalid
240+
centre-id in a link channel
241+
"""
242+
243+
with open(get_test_file_path('data/wcmp2-failing-invalid-link-channel-centre-id.json')) as fh: # noqa
244+
record = json.load(fh)
245+
ts = WMOCoreMetadataProfileTestSuite2(record)
246+
results = ts.run_tests()
247+
248+
codes = [r['code'] for r in results['tests']]
249+
250+
self.assertEqual(codes.count('FAILED'), 1)
251+
self.assertEqual(codes.count('PASSED'), 11)
252+
self.assertEqual(codes.count('SKIPPED'), 0)
253+
237254

238255
class WCMP2KPITest(unittest.TestCase):
239256
"""WCMP KPI tests of tests"""

0 commit comments

Comments
 (0)