-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pgvernum.py
159 lines (139 loc) · 7.65 KB
/
test_pgvernum.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import unittest
import pgversion as v
class TestMethods(unittest.TestCase):
def test_getPGVerNumFromString(self):
self.assertEqual(v.getPGVerNumFromString('9.3.14'), 90314)
self.assertEqual(v.getPGVerNumFromString('9.6.1'), 90601)
self.assertEqual(v.getPGVerNumFromString('10.0'), 100000)
self.assertEqual(v.getPGVerNumFromString('10.14'), 100014)
self.assertEqual(v.getPGVerNumFromString('11.1'), 110001)
self.assertEqual(v.getPGVerNumFromString('9.3.14'), 90314)
self.assertEqual(v.getPGVerNumFromString('11.9999'), 119999)
def test_getPGVersionString_negatives(self):
self.assertEqual(v.getPGVerNumFromString('9'), False)
self.assertEqual(v.getPGVerNumFromString('9.6'), False)
self.assertEqual(v.getPGVerNumFromString('10'), False)
self.assertEqual(v.getPGVerNumFromString('9.3.1.1'), False)
self.assertEqual(v.getPGVerNumFromString('10.1.1'), False)
self.assertEqual(v.getPGVerNumFromString('9.3.1a'), False)
self.assertEqual(v.getPGVerNumFromString('10.1b'), False)
self.assertEqual(v.getPGVerNumFromString('9.3.99'), False)
self.assertEqual(v.getPGVerNumFromString('9.99.1'), False)
def test_isValidPGVersion_negatives(self):
self.assertEqual(v.isValidPGVersion(''), False)
self.assertEqual(v.isValidPGVersion('a'), False)
self.assertEqual(v.isValidPGVersion('a.a'), False)
self.assertEqual(v.isValidPGVersion('a.a.a'), False)
self.assertEqual(v.isValidPGVersion('.'), False)
self.assertEqual(v.isValidPGVersion('..'), False)
self.assertEqual(v.isValidPGVersion('...'), False)
self.assertEqual(v.isValidPGVersion('1'), False)
self.assertEqual(v.isValidPGVersion('9'), False)
self.assertEqual(v.isValidPGVersion('9.4'), False)
self.assertEqual(v.isValidPGVersion('.9.4'), False)
self.assertEqual(v.isValidPGVersion('9.4.'), False)
self.assertEqual(v.isValidPGVersion('94'), False)
self.assertEqual(v.isValidPGVersion('9.4.4.4'), False)
self.assertEqual(v.isValidPGVersion('9.4.4.4.4'), False)
self.assertEqual(v.isValidPGVersion('9b.2.4'), False)
self.assertEqual(v.isValidPGVersion('b9.2.12'), False)
self.assertEqual(v.isValidPGVersion('b.2.2'), False)
self.assertEqual(v.isValidPGVersion('9.b2.12'), False)
self.assertEqual(v.isValidPGVersion('9.2b.12'), False)
self.assertEqual(v.isValidPGVersion('9.b.12'), False)
self.assertEqual(v.isValidPGVersion('9.2.b12'), False)
self.assertEqual(v.isValidPGVersion('9.2.12b'), False)
self.assertEqual(v.isValidPGVersion('9.2.b'), False)
self.assertEqual(v.isValidPGVersion('-9.3.1'), False)
self.assertEqual(v.isValidPGVersion('9.-3.1'), False)
self.assertEqual(v.isValidPGVersion('9.3.-1'), False)
self.assertEqual(v.isValidPGVersion('11.1.1'), False)
self.assertEqual(v.isValidPGVersion('11.1.'), False)
self.assertEqual(v.isValidPGVersion('.11.1'), False)
self.assertEqual(v.isValidPGVersion('11.1a'), False)
self.assertEqual(v.isValidPGVersion('11.a1'), False)
self.assertEqual(v.isValidPGVersion('11.a'), False)
self.assertEqual(v.isValidPGVersion('11a.1'), False)
self.assertEqual(v.isValidPGVersion('a11.1'), False)
self.assertEqual(v.isValidPGVersion('9..'), False)
self.assertEqual(v.isValidPGVersion('9..1'), False)
self.assertEqual(v.isValidPGVersion('11..'), False)
self.assertEqual(v.isValidPGVersion('11.'), False)
self.assertEqual(v.isValidPGVersion('11.10000'), False)
self.assertEqual(v.isValidPGVersion('9.6.100'), False)
self.assertEqual(v.isValidPGVersion('9.7.10'), False)
self.assertEqual(v.isValidPGVersion('9.100.10'), False)
self.assertEqual(v.isValidPGVersion('#'), False)
def test_isValidPGVersion_positives(self):
self.assertEqual(v.isValidPGVersion('9.3.0'), True)
self.assertEqual(v.isValidPGVersion('11.1'), True)
def test_isReleasedPGVersion_positives(self):
self.assertEqual(v.isReleasedPGVersion('9.3.0'), True)
self.assertEqual(v.isReleasedPGVersion('11.1'), True)
def test_isReleasedPGVersion_negatives(self):
self.assertEqual(v.isReleasedPGVersion(''), False)
self.assertEqual(v.isReleasedPGVersion('10.24'), False)
def test_getMajorPGVersion_positives(self):
self.assertEqual(v.getMajorPGVersion('9.3'), 9.3)
self.assertEqual(v.getMajorPGVersion('9.3.0'), 9.3)
self.assertEqual(v.getMajorPGVersion('11.1'), 11)
self.assertEqual(v.getMajorPGVersion('11.0'), 11)
self.assertEqual(v.getMajorPGVersion('11'), 11)
def test_getMajorPGVersion_negatives(self):
self.assertEqual(v.getMajorPGVersion('9'), False)
self.assertEqual(v.getMajorPGVersion('11.2.2'), False)
self.assertEqual(v.getMajorPGVersion('a'), False)
def test_getMinorPGVersion_positives(self):
self.assertEqual(v.getMinorPGVersion('9.3.0'), False)
self.assertEqual(v.getMinorPGVersion('11.1'), True)
def test_getMinorPGVersion_negatives(self):
self.assertEqual(v.getMinorPGVersion('9.3'), False)
self.assertEqual(v.getMinorPGVersion('11'), False)
def test_parsePGVersion_positives(self):
self.assertEqual(v.parsePGVersion('9.3.0'), [9.3, 0])
self.assertEqual(v.parsePGVersion('11.1'), [11,1])
def test_parsePGVersion_negatives(self):
self.assertEqual(v.parsePGVersion('9.3'), False)
self.assertEqual(v.parsePGVersion('11'), False)
def test_appendMinorVersionIfRequired_positives(self):
self.assertEqual(v.appendMinorVersionIfRequired('9.3'), '9.3.0')
self.assertEqual(v.appendMinorVersionIfRequired('11'), '11.0')
def test_appendMinorVersionIfRequired_negatives(self):
self.assertEqual(v.appendMinorVersionIfRequired('9.3.2'), '9.3.2')
self.assertEqual(v.appendMinorVersionIfRequired('11.1a'), '11.1a')
def test_convToYYYYMMDD(self):
self.assertEqual(v.convToYYYYMMDD('2023-02-01'), 20230201)
def test_getVerReleaseDate_positives(self):
self.assertEqual(v.getVerReleaseDate('12.1'), '2019-11-14')
self.assertEqual(v.getVerReleaseDate('12.0'), '2019-10-03')
self.assertEqual(v.getVerReleaseDate('10.1'), '2017-11-09')
def test_getVerReleaseDate_negatives(self):
self.assertEqual(v.getVerReleaseDate('12.100'), '0')
self.assertEqual(v.getVerReleaseDate('12.'), '0')
self.assertEqual(v.getVerReleaseDate('12.a'), '0')
self.assertEqual(v.getVerReleaseDate('1232'), '0')
self.assertEqual(v.getVerReleaseDate('-1'), '0')
def test_IsVerReleasedAfter_positives(self):
self.assertEqual(v.IsVerReleasedAfter('12.1', '11.5'), True)
self.assertEqual(v.IsVerReleasedAfter('9.4.23', '9.5.15'), True)
self.assertEqual(v.IsVerReleasedAfter('12.0', '12.1'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '11.6'), False)
def test_IsVerReleasedAfter_negatives(self):
self.assertEqual(v.IsVerReleasedAfter('121', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('121', '120'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '120'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '13.1'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', 'a'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', ''), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '#'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '.'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '..'), False)
self.assertEqual(v.IsVerReleasedAfter('12.1', '...'), False)
self.assertEqual(v.IsVerReleasedAfter('a', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('.', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('..', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('...', '12.0'), False)
self.assertEqual(v.IsVerReleasedAfter('#', '12.0'), False)
if __name__ == '__main__':
unittest.main(failfast=True)