blob: b2a5e556b5ab5b80235d986a4f9b4ada74723299 (
plain) (
blame)
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
|
from build.plugins.lib.nots.semver import Version, Operator, VersionRange
def test_from_str():
# arrange
range_str = ">= 1.2.3"
# act
range = VersionRange.from_str(range_str)
# assert
assert isinstance(range, VersionRange)
assert range.operator == Operator.GE
def test_from_str_no_operator():
# arrange
range_str = r"¯\_(ツ)_/¯"
error = None
# act
try:
VersionRange.from_str(range_str)
except Exception as exception:
error = exception
# assert
assert isinstance(error, ValueError)
assert str(error) == "Unsupported version range: '{}'. Currently we only support ranges formatted like so: '>= 1.2.3'".format(range_str)
def test_init():
# arrange
operator = Operator.GE
version = Version.from_str("1.2.3")
# act
range = VersionRange(operator, version)
# assert
assert range.operator == Operator.GE
assert range.version == Version(1, 2, 3)
def test_is_satisfied_by_starts_with():
# arrange
version = Version.from_str("1.2.3")
range = VersionRange.from_str(">= 1.2.3")
# act + assert
assert range.is_satisfied_by(version)
def test_is_satisfied_by_includes():
# arrange
version = Version.from_str("5.8.2")
range = VersionRange.from_str(">= 1.2.3")
# act + assert
assert range.is_satisfied_by(version)
def test_is_satisfied_by_not_includes():
# arrange
version = Version.from_str("1.2.2")
range = VersionRange.from_str(">= 1.2.3")
# act + assert
assert not range.is_satisfied_by(version)
|