-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_add_version.py
More file actions
78 lines (61 loc) · 1.25 KB
/
test_add_version.py
File metadata and controls
78 lines (61 loc) · 1.25 KB
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 utils.transforms import add_version_if_missing
import yaml
def test_add_version_with_format():
payload = '''
_format_version: '3.0'
services:
- host: myservice
name: my-service
tags:
- ns.mytest
- another
'''
y = yaml.load(payload, Loader=yaml.FullLoader)
add_version_if_missing(y)
result = yaml.dump(y, indent=2)
assert payload.strip() == result.strip()
def test_add_version_if_missing():
payload = '''
services:
- host: myservice
name: my-service
tags:
- ns.mytest
- another
'''
expected = '''
_format_version: '3.0'
services:
- host: myservice
name: my-service
tags:
- ns.mytest
- another
'''
y = yaml.load(payload, Loader=yaml.FullLoader)
add_version_if_missing(y)
result = yaml.dump(y, indent=2)
assert expected.strip() == result.strip()
def test_add_version_with_v1():
payload = '''
_format_version: 1.0
services:
- host: myservice
name: my-service
tags:
- ns.mytest
- another
'''
expected = '''
_format_version: '3.0'
services:
- host: myservice
name: my-service
tags:
- ns.mytest
- another
'''
y = yaml.load(payload, Loader=yaml.FullLoader)
add_version_if_missing(y)
result = yaml.dump(y, indent=2)
assert expected.strip() == result.strip()