-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathtest_dependency_upgrader.py
53 lines (43 loc) · 2.59 KB
/
test_dependency_upgrader.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
from __future__ import absolute_import
import pytest
pytestmark = pytest.mark.unit
from dependency_upgrader import (
_MAJOR,
_MINOR,
_PATCH,
_get_dependency_upper_bound_for_pythonesque,
_get_dependency_upper_bound_for_runtime_upgrade,
_get_dependency_upper_bound_for_semver,
)
def test_get_dependency_upper_bound_for_runtime_upgrade():
# case 1: Runtime upgrade type is MINOR, dependency name is python => use pythonesque
assert _get_dependency_upper_bound_for_runtime_upgrade("python", "1.2.5", _MINOR) == ",<1.3.0"
# case 1: Runtime upgrade type is MINOR, dependency name is node => use semver
assert _get_dependency_upper_bound_for_runtime_upgrade("node", "1.2.5", _MINOR) == ",<2.0.0"
def test_get_dependency_upper_bound_for_semver():
# case 1: Runtime upgrade type is MAJOR.
assert _get_dependency_upper_bound_for_semver("1.2.5", _MAJOR) == ""
# case 2: Runtime upgrade type is MINOR.
assert _get_dependency_upper_bound_for_semver("1.2.5", _MINOR) == ",<2.0.0"
# case 3: Runtime upgrade type is PATCH.
assert _get_dependency_upper_bound_for_semver("1.2.5", _PATCH) == ",<1.3.0"
# case 4: Throw exception for any other runtime_upgrade_type
with pytest.raises(Exception):
_get_dependency_upper_bound_for_semver("1.2.5", "prerelease")
def test_get_dependency_upper_bound_for_pythonesque():
# case 1: Runtime upgrade type is MAJOR.
assert _get_dependency_upper_bound_for_pythonesque("1.2.5", _MAJOR) == ""
# case 2: Runtime upgrade type is MINOR.
assert _get_dependency_upper_bound_for_pythonesque("1.2.5", _MINOR) == ",<1.3.0"
# case 3: Runtime upgrade type is PATCH. For pythonesque, we will bump minor version.
assert _get_dependency_upper_bound_for_pythonesque("1.2.5", _PATCH) == ",<1.3.0"
# case 4: Throw exception for any other runtime_upgrade_type
with pytest.raises(Exception):
_get_dependency_upper_bound_for_pythonesque("1.2.5", "prerelease")
def test_get_dependency_upper_bound_for_post_pre_release():
assert _get_dependency_upper_bound_for_runtime_upgrade("python", "1.2.5.post1", _PATCH) == ",<1.3.0"
assert _get_dependency_upper_bound_for_runtime_upgrade("node", "1.2.5.post1", _PATCH) == ",<1.3.0"
assert _get_dependency_upper_bound_for_runtime_upgrade("python", "1.2.5.post1", _MINOR) == ",<1.3.0"
assert _get_dependency_upper_bound_for_runtime_upgrade("node", "1.2.5.post1", _MINOR) == ",<2.0.0"
assert _get_dependency_upper_bound_for_runtime_upgrade("python", "1.2.5.post1", _MAJOR) == ""
assert _get_dependency_upper_bound_for_runtime_upgrade("node", "1.2.5.post1", _MAJOR) == ""