diff --git a/scripts/release_delivery.py b/scripts/release_delivery.py index 32aeead..0096654 100644 --- a/scripts/release_delivery.py +++ b/scripts/release_delivery.py @@ -40,7 +40,7 @@ def command(*args, data=None, optional=False, env=None): def api(repo, path, optional=False): - raw = command('gh', 'api', f'repos/{repo}/{path}', optional=optional) + raw = command('gh', 'api', f'repos/{repo}/{path}'.rstrip('/'), optional=optional) return json.loads(raw) if raw is not None else None diff --git a/tests/test_release_delivery.py b/tests/test_release_delivery.py index 80a6971..063f243 100644 --- a/tests/test_release_delivery.py +++ b/tests/test_release_delivery.py @@ -17,6 +17,13 @@ spec.loader.exec_module(delivery) +class APITransportTests(unittest.TestCase): + def test_repository_metadata_uses_canonical_api_root(self): + with patch.object(delivery, 'command', return_value=b'{}') as command: + self.assertEqual(delivery.api(delivery.APP, ''), {}) + command.assert_called_once_with('gh', 'api', 'repos/' + delivery.APP, optional=False) + + class DeliveryTests(unittest.TestCase): def setUp(self): self.sha = 'a' * 40