19
19
import unittest
20
20
21
21
from functools import wraps
22
-
23
22
from urllib .request import urlopen
24
23
from urllib .error import HTTPError
25
24
from urllib .parse import urljoin
28
27
29
28
if hasattr (sys , 'argv' ):
30
29
arglist = ['--test-repositories' ]
31
- # Exctract used arguments form the commandline an strip them for
30
+ # Extract used arguments from commandline an strip them for
32
31
# unittest.main
33
32
userargs = [arg for arg in sys .argv if arg in arglist ]
34
33
for arg in userargs :
@@ -172,28 +171,27 @@ def setUpClass(cls):
172
171
'Theme - Default' , 'Vintage' , 'XML' , 'YAML'
173
172
)
174
173
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 / [^/#?]+ / [^/#? ]+
178
177
) $'''
179
178
# Strip multilines for better debug info on failures
180
179
rel_b_reg = ' ' .join (map (str .strip , rel_b_reg .split ()))
181
180
release_base_regex = re .compile (rel_b_reg , re .X )
182
181
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/ [^#?]*[^/#?] | / )?
190
188
) $'''
191
189
pac_d_reg = ' ' .join (map (str .strip , pac_d_reg .split ()))
192
190
package_details_regex = re .compile (pac_d_reg , re .X )
193
191
194
192
def _test_repository_keys (self , include , data ):
195
193
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" )
197
195
self .assertIn ('schema_version' , data )
198
196
self .assertEqual (data ['schema_version' ], '4.0.0' )
199
197
@@ -516,10 +514,10 @@ def check_release_key_values(self, data, library):
516
514
self .assertCountEqual (v , list (set (v )),
517
515
"Specifying the same platform multiple times is redundant" )
518
516
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" )
523
521
524
522
self .assertFalse (set (["osx" , "windows" , "linux" ]) == set (v ),
525
523
'"osx, windows, linux" are similar to (and should be replaced by) "*"' )
@@ -531,14 +529,6 @@ def check_release_key_values(self, data, library):
531
529
elif k == 'date' :
532
530
self .assertRegex (v , r"^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$" )
533
531
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
-
542
532
elif k == 'tags' :
543
533
self .assertTrue (bool (v ),
544
534
'"tags" must be `true` or a string of length>0' )
@@ -736,10 +726,18 @@ def tearDownClass(cls):
736
726
print ("Repositories skipped: %s" % dict (cls .skipped_repositories ))
737
727
738
728
def test_channel_keys (self ):
729
+ allowed_keys = ("$schema" , 'repositories' , 'schema_version' )
739
730
keys = sorted (self .j .keys ())
740
- self .assertEqual (keys , ['$schema' , 'repositories' , 'schema_version' ])
741
731
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 )
742
738
self .assertEqual (self .j ['schema_version' ], '4.0.0' )
739
+
740
+ self .assertIn ('repositories' , keys )
743
741
self .assertIsInstance (self .j ['repositories' ], list )
744
742
745
743
for repo in self .j ['repositories' ]:
0 commit comments