Skip to content

Commit 7e1cd97

Browse files
committed
Merge branch 'pr/update-tests' into four-point-oh
2 parents 6514912 + 720c5fb commit 7e1cd97

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

tests/test.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import unittest
2020

2121
from functools import wraps
22-
2322
from urllib.request import urlopen
2423
from urllib.error import HTTPError
2524
from urllib.parse import urljoin
@@ -28,7 +27,7 @@
2827

2928
if hasattr(sys, 'argv'):
3029
arglist = ['--test-repositories']
31-
# Exctract used arguments form the commandline an strip them for
30+
# Extract used arguments from commandline an strip them for
3231
# unittest.main
3332
userargs = [arg for arg in sys.argv if arg in arglist]
3433
for arg in userargs:
@@ -172,28 +171,27 @@ def setUpClass(cls):
172171
'Theme - Default', 'Vintage', 'XML', 'YAML'
173172
)
174173

175-
rel_b_reg = r'''^ (https:// github\.com/ [^/]+/ [^/]+
176-
|https:// bitbucket\.org/ [^/]+/ [^/]+
177-
|https:// gitlab\.com/ [^/]+/ [^/]+
174+
rel_b_reg = r'''^ ( https:// bitbucket\.org / [^/#?]+ / [^/#?]+
175+
| https:// github\.com / [^/#?]+ / [^/#?]+
176+
| https:// gitlab\.com / [^/#?]+ / [^/#?]+
178177
) $'''
179178
# Strip multilines for better debug info on failures
180179
rel_b_reg = ' '.join(map(str.strip, rel_b_reg.split()))
181180
release_base_regex = re.compile(rel_b_reg, re.X)
182181

183-
pac_d_reg = r'''^ (https:// github\.com/ [^/]+/ [^/]+ (/tree/ .+ (?<!/)
184-
|/)? (?<!\.git)
185-
|https:// bitbucket\.org/ [^/]+/ [^/]+ (/src/ .+ (?<!/)
186-
|\#tags
187-
|/)?
188-
|https:// gitlab\.com/ [^/]+/ [^/]+ (/-/tree/ .+ (?<!/)
189-
|/)? (?<!\.git)
182+
pac_d_reg = r'''^ ( https:// bitbucket\.org/ [^/#?]+/ [^/#?]+
183+
( /src/ [^#?]*[^/#?] | \#tags | / )?
184+
| https:// github\.com/ [^/#?]+/ [^/#?]+
185+
(?<!\.git) ( /tree/ [^#?]*[^/#?] | / )?
186+
| https:// gitlab\.com/ [^/#?]+/ [^/#?]+
187+
(?<!\.git) ( /-/tree/ [^#?]*[^/#?] | / )?
190188
) $'''
191189
pac_d_reg = ' '.join(map(str.strip, pac_d_reg.split()))
192190
package_details_regex = re.compile(pac_d_reg, re.X)
193191

194192
def _test_repository_keys(self, include, data):
195193
keys = ('$schema', 'schema_version', 'packages', 'libraries', 'includes')
196-
self.assertTrue(2 <= len(data) <= 4, "Unexpected number of keys")
194+
self.assertTrue(2 <= len(data) <= len(keys), "Unexpected number of keys")
197195
self.assertIn('schema_version', data)
198196
self.assertEqual(data['schema_version'], '4.0.0')
199197

@@ -516,10 +514,10 @@ def check_release_key_values(self, data, library):
516514
self.assertCountEqual(v, list(set(v)),
517515
"Specifying the same platform multiple times is redundant")
518516

519-
if (("osx-x32" in v and "osx-x64" in v) or
520-
("windows-x32" in v and "windows-x64" in v) or
521-
("linux-x32" in v and "linux-x64" in v)):
522-
self.fail("Specifying both x32 and x64 architectures is redundant")
517+
if (("osx-x32" in v and "osx-x64" in v and "osx-arm64" in v) or
518+
("windows-x32" in v and "windows-x64" in v and "windows-arm64" in v) or
519+
("linux-x32" in v and "linux-x64" in v and "linux-arm64" in v)):
520+
self.fail("Specifying all of x32, x64 and arm64 architectures is redundant")
523521

524522
self.assertFalse(set(["osx", "windows", "linux"]) == set(v),
525523
'"osx, windows, linux" are similar to (and should be replaced by) "*"')
@@ -531,14 +529,6 @@ def check_release_key_values(self, data, library):
531529
elif k == 'date':
532530
self.assertRegex(v, r"^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$")
533531

534-
elif k == 'url':
535-
self.assertRegex(v, r'^https?://')
536-
537-
elif k == 'base':
538-
self.assertRegex(v, self.release_base_regex,
539-
'The base url is badly formatted or '
540-
'invalid')
541-
542532
elif k == 'tags':
543533
self.assertTrue(bool(v),
544534
'"tags" must be `true` or a string of length>0')
@@ -736,10 +726,18 @@ def tearDownClass(cls):
736726
print("Repositories skipped: %s" % dict(cls.skipped_repositories))
737727

738728
def test_channel_keys(self):
729+
allowed_keys = ("$schema", 'repositories', 'schema_version')
739730
keys = sorted(self.j.keys())
740-
self.assertEqual(keys, ['$schema', 'repositories', 'schema_version'])
741731

732+
self.assertTrue(2 <= len(keys) <= len(allowed_keys), "Unexpected number of keys")
733+
734+
for k in keys:
735+
self.assertIn(k, allowed_keys, "Unexpected key")
736+
737+
self.assertIn('schema_version', keys)
742738
self.assertEqual(self.j['schema_version'], '4.0.0')
739+
740+
self.assertIn('repositories', keys)
743741
self.assertIsInstance(self.j['repositories'], list)
744742

745743
for repo in self.j['repositories']:

0 commit comments

Comments
 (0)