-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_version.py
94 lines (71 loc) · 3.2 KB
/
test_version.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
from version import get_next_version
def test_get_next_version_major():
release_type = "major"
prefix = "dev"
for tags in ([], None):
version = get_next_version(prefix, tags, release_type)
assert str(version) == '0.0'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '2.0']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '3.0'
# much less sense but should be tested
tags = ['1.0', '1.1']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '2.0'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '1.1', '2.0-dev2', '1.2',]
version = get_next_version(prefix, tags, release_type)
assert str(version) == '2.0'
tags = ['0.23.0', '0.24.1', '0.23.1', '0.24.0', '0.23.2']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '25.0'
def test_get_next_version_patch():
release_type = "patch"
prefix = "dev"
for tags in ([], None):
version = get_next_version(prefix, tags, release_type)
assert str(version) == '0.0'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '2.0']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '2.1'
# much less sense but should be tested
tags = ['1.0', '1.1']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '1.2'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '1.1', '2.0-dev2', '1.2',]
version = get_next_version(prefix, tags, release_type)
assert str(version) == '1.3'
tags = ['0.23.0', '0.24.1', '0.23.1', '0.24.0', '0.23.2']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '24.2'
def test_get_next_version_increment():
release_type = "increment"
prefix = "dev"
for tags in ([], None):
version = get_next_version(prefix, tags, release_type)
assert str(version) == '0.0-dev0'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '2.0']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '3.0-dev0'
# much less sense but should be tested
tags = ['1.0', '1.1']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '2.0-dev0'
tags = ['1.0', '2.0-dev0', '2.0-dev1', '1.1', '2.0-dev2', '1.2',]
version = get_next_version(prefix, tags, release_type)
assert str(version) == '2.0-dev3'
tags = ['0.23.0', '0.24.1', '0.23.1', '0.24.0', '0.23.2']
version = get_next_version(prefix, tags, release_type)
assert str(version) == '25.0-dev0'
def test_get_next_version_special_cases():
prefix = "dev"
tags = ['2.0-dev0', '1.1', 'stable', '2.0-dev2', '0.2.2.3', '2.0-dev1', '1.2', '1.0',]
assert str(get_next_version(prefix, tags, "increment")) == '2.0-dev3'
assert str(get_next_version(prefix, tags, "patch")) == '1.3'
assert str(get_next_version(prefix, tags, "major")) == '2.0'
tags = ['stable']
assert str(get_next_version(prefix, tags, "major")) == '0.0'
def test_get_next_version_unsorted():
prefix = "dev"
tags = ['26.0', '26.0-dev0']
assert str(get_next_version(prefix, tags, "increment")) == '27.0-dev0'
assert str(get_next_version(prefix, tags, "major")) == '27.0'