Skip to content

Commit 1a41f82

Browse files
author
deathaxe
committed
Unittests: Add support for assets
1 parent 7a1e586 commit 1a41f82

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/test.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ def _test_library(self, include, data):
403403

404404
pck_release_key_types_map = {
405405
'base': str,
406+
'asset': str,
406407
'tags': (bool, str),
407408
'branch': str,
408409
'sublime_text': str,
@@ -416,6 +417,7 @@ def _test_library(self, include, data):
416417

417418
dep_release_key_types_map = {
418419
'base': str,
420+
'asset': str,
419421
'tags': (bool, str),
420422
'branch': str,
421423
'sublime_text': str,
@@ -433,22 +435,22 @@ def _test_release(self, package_name, data, library, main_repo=True):
433435
if library:
434436
condition = (
435437
'base' in data
436-
and ('tags' in data or 'branch' in data)
438+
and any(d in data for d in ('asset', 'tags', 'branch'))
437439
or ('sha256' in data
438440
and ('url' not in data
439441
or data['url'].startswith('http://')))
440442
)
441443
self.assertTrue(condition,
442-
'A release must have a "base" and a "tags" or "branch" key '
444+
'A release must have a "base" and an "asset", "tags" or "branch" key '
443445
'if it is in the main repository. For custom '
444446
'releases, a custom repository.json file must be '
445447
'hosted elsewhere. The only exception to this rule '
446448
'is for packages that can not be served over HTTPS '
447449
'since they help bootstrap proper secure HTTP '
448450
'support for Sublime Text.')
449451
else:
450-
self.assertTrue(('tags' in data or 'branch' in data),
451-
'A release must have a "tags" key or "branch" key '
452+
self.assertTrue(any(d in data for d in ('asset', 'tags', 'branch')),
453+
'A release must have an "asset", "tags" or "branch" key '
452454
'if it is in the main repository. For custom '
453455
'releases, a custom repository.json file must be '
454456
'hosted elsewhere.')
@@ -458,7 +460,7 @@ def _test_release(self, package_name, data, library, main_repo=True):
458460
'used in the main repository since a pull '
459461
'request would be necessary for every release')
460462

461-
elif 'tags' not in data and 'branch' not in data:
463+
elif not any(d in data for d in ('asset', 'tags', 'branch')):
462464
if library:
463465
for key in ('url', 'version'):
464466
self.assertIn(key, data,
@@ -481,6 +483,10 @@ def _test_release(self, package_name, data, library, main_repo=True):
481483
'A release must have only one of the "tags" or '
482484
'"branch" keys.')
483485

486+
self.assertFalse(('asset' in data and 'branch' in data),
487+
'A release must have only one of the "asset" or '
488+
'"branch" keys.')
489+
484490
# Test keys values
485491
self.check_release_key_values(data, library)
486492

0 commit comments

Comments
 (0)