-
Notifications
You must be signed in to change notification settings - Fork 14
/
test_travisparse.py
64 lines (59 loc) · 2.05 KB
/
test_travisparse.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
""" Nosetests for travis2bashes script
"""
from __future__ import absolute_import, print_function
import os
import sys
sys.path.append(os.path.dirname(__file__))
from travisparse import get_envs, TravisError
import pytest
def test_get_envs():
# Get fetch of environment from .travis.yml
assert get_envs({}) == ''
assert get_envs(dict(install = ['something'])) == ''
yaml = dict(env = {'global': ['LATEST_TAG=1'],
'matrix': ['VERSION=2.7.8 NUMPY_VERSION=1.6.1',
'VERSION=3.3.5 NUMPY_VERSION=1.7.1',
'VERSION=3.4.1 NUMPY_VERSION=1.7.1']})
assert (get_envs(yaml) ==
"""LATEST_TAG=1
VERSION=2.7.8 NUMPY_VERSION=1.6.1
""")
yaml = dict(env = {'matrix': ['VERSION=2.7.8 NUMPY_VERSION=1.6.1',
'VERSION=3.3.5 NUMPY_VERSION=1.7.1',
'VERSION=3.4.1 NUMPY_VERSION=1.7.1']})
assert (get_envs(yaml) ==
"""VERSION=2.7.8 NUMPY_VERSION=1.6.1
""")
yaml = dict(env = ['ISOLATED=true', 'ISOLATED=false'])
assert (get_envs(yaml) ==
"""ISOLATED=true
""")
# excludes too complicated
yaml = dict(env = {'matrix':
{'exclude':
[{'gemfile': 'Gemfile', 'rvm': '2.0.0'}]}})
with pytest.raises(TravisError):
get_envs(yaml)
# includes too complicated
yaml = dict(env = {'matrix':
{'include':
[{'gemfile': 'gemfiles/Gemfile.rails-3.2.x',
'rvm': 'ruby-head',
'env': 'ISOLATED=false'}]}})
with pytest.raises(TravisError):
get_envs(yaml)
# global implies matrix
yaml = dict(env = {'global': ['LATEST_TAG=1']})
with pytest.raises(TravisError):
get_envs(yaml)
# one line is OK too
yaml = dict(env = {'global': 'LATEST_TAG=1',
'matrix': 'VERSION=3.3.1'})
assert (get_envs(yaml) ==
"""LATEST_TAG=1
VERSION=3.3.1
""")
yaml = dict(env = 'MY_VAR=1')
assert (get_envs(yaml) ==
"""MY_VAR=1
""")