Skip to content

Commit

Permalink
Unittests: Add support for assets
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Nov 10, 2023
1 parent 7a1e586 commit 1a41f82
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def _test_library(self, include, data):

pck_release_key_types_map = {
'base': str,
'asset': str,
'tags': (bool, str),
'branch': str,
'sublime_text': str,
Expand All @@ -416,6 +417,7 @@ def _test_library(self, include, data):

dep_release_key_types_map = {
'base': str,
'asset': str,
'tags': (bool, str),
'branch': str,
'sublime_text': str,
Expand All @@ -433,22 +435,22 @@ 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 '
'is for packages that can not be served over HTTPS '
'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.')
Expand All @@ -458,7 +460,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,
Expand All @@ -481,6 +483,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)

Expand Down

0 comments on commit 1a41f82

Please sign in to comment.