-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathutil_tests.py
78 lines (61 loc) · 3.4 KB
/
util_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from osclib.util import project_list_family
from osclib.util import project_list_family_prior
from osclib.util import project_list_family_sorter
from osclib import util
import unittest
class TestUtil(unittest.TestCase):
def setUp(self):
util._project_list_prefix = util.project_list_prefix
def project_list_prefix_replacement(apiurl, prefix):
if prefix == 'openSUSE:Leap':
return [
'openSUSE:Leap:15.0',
'openSUSE:Leap:15.0:Update',
'openSUSE:Leap:15.0:NonFree',
'openSUSE:Leap:15.0:NonFree:Update',
'openSUSE:Leap:42.2',
'openSUSE:Leap:42.3',
'openSUSE:Leap:42.3:Update',
'openSUSE:Leap:42.3:NonFree',
'openSUSE:Leap:42.3:NonFree:Update',
]
elif prefix == 'SUSE':
return [
# Names reflect IBS as OBS differs for no apparent reason.
'SUSE:SLE-12:GA',
'SUSE:SLE-12-SP1:GA',
'SUSE:SLE-12-SP1:Update',
'SUSE:SLE-15:GA',
]
return []
util.project_list_prefix = project_list_prefix_replacement
def tearDown(self):
util.project_list_prefix = util._project_list_prefix
def test_project_list_family(self):
self.assertEqual(project_list_family(None, 'openSUSE:Factory'), ['openSUSE:Factory'])
expected = ['openSUSE:Leap:15.0', 'openSUSE:Leap:42.2', 'openSUSE:Leap:42.3']
self.assertEqual(expected, project_list_family(None, 'openSUSE:Leap:15.0'))
self.assertEqual(expected, project_list_family(None, 'openSUSE:Leap:42.3'))
expected = ['SUSE:SLE-12:GA', 'SUSE:SLE-12-SP1:GA', 'SUSE:SLE-15:GA']
self.assertEqual(expected, project_list_family(None, 'SUSE:SLE-15:GA'))
self.assertEqual(expected, project_list_family(None, 'SUSE:SLE-15-SP1:GA'))
def test_project_list_family_sorter(self):
projects = sorted(project_list_family(None, 'openSUSE:Leap:15.0'), key=project_list_family_sorter)
self.assertEqual(projects[0], 'openSUSE:Leap:42.2')
self.assertEqual(projects[2], 'openSUSE:Leap:15.0')
projects = sorted(project_list_family(None, 'SUSE:SLE-15:GA'), key=project_list_family_sorter)
self.assertEqual(projects[0], 'SUSE:SLE-12:GA')
self.assertEqual(projects[2], 'SUSE:SLE-15:GA')
def test_project_list_family_prior(self):
projects = project_list_family_prior(None, 'openSUSE:Leap:15.0', include_self=True)
self.assertEqual(projects, ['openSUSE:Leap:15.0', 'openSUSE:Leap:42.3', 'openSUSE:Leap:42.2'])
projects = project_list_family_prior(None, 'openSUSE:Leap:15.0')
self.assertEqual(projects, ['openSUSE:Leap:42.3', 'openSUSE:Leap:42.2'])
projects = project_list_family_prior(None, 'openSUSE:Leap:15.0', last='openSUSE:Leap:42.3')
self.assertEqual(projects, ['openSUSE:Leap:42.3'])
projects = project_list_family_prior(None, 'openSUSE:Leap:42.3')
self.assertEqual(projects, ['openSUSE:Leap:42.2'])
projects = project_list_family_prior(None, 'SUSE:SLE-15:GA')
self.assertEqual(projects, ['SUSE:SLE-12-SP1:GA', 'SUSE:SLE-12:GA'])
projects = project_list_family_prior(None, 'SUSE:SLE-12-SP1:GA')
self.assertEqual(projects, ['SUSE:SLE-12:GA'])