From 4d5a09cbec4bea89ed0d0c3a383169d97b757421 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 10 Nov 2023 17:59:04 +0100 Subject: [PATCH] Unittests: Add support for assets --- tests/test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test.py b/tests/test.py index 383e3efe646..dda8bec15ef 100644 --- a/tests/test.py +++ b/tests/test.py @@ -433,13 +433,13 @@ def _test_release(self, package_name, data, library, main_repo=True): if library: condition = ( 'base' in data - and ('tags' in data or 'branch' in data) + and any(d in data for d in ('asset', 'tags', 'branch')) or ('sha256' in data and ('url' not in data or data['url'].startswith('http://'))) ) self.assertTrue(condition, - 'A release must have a "base" and a "tags" or "branch" key ' + 'A release must have a "base" and an "asset", "tags" or "branch" key ' 'if it is in the main repository. For custom ' 'releases, a custom repository.json file must be ' 'hosted elsewhere. The only exception to this rule ' @@ -447,8 +447,8 @@ def _test_release(self, package_name, data, library, main_repo=True): 'since they help bootstrap proper secure HTTP ' 'support for Sublime Text.') else: - self.assertTrue(('tags' in data or 'branch' in data), - 'A release must have a "tags" key or "branch" key ' + self.assertTrue(any(d in data for d in ('asset', 'tags', 'branch')), + 'A release must have an "asset", "tags" or "branch" key ' 'if it is in the main repository. For custom ' 'releases, a custom repository.json file must be ' 'hosted elsewhere.') @@ -458,7 +458,7 @@ def _test_release(self, package_name, data, library, main_repo=True): 'used in the main repository since a pull ' 'request would be necessary for every release') - elif 'tags' not in data and 'branch' not in data: + elif not any(d in data for d in ('asset', 'tags', 'branch')): if library: for key in ('url', 'version'): self.assertIn(key, data, @@ -481,6 +481,10 @@ def _test_release(self, package_name, data, library, main_repo=True): 'A release must have only one of the "tags" or ' '"branch" keys.') + self.assertFalse(('asset' in data and 'branch' in data), + 'A release must have only one of the "asset" or ' + '"branch" keys.') + # Test keys values self.check_release_key_values(data, library)