1
|
|
|
# pylint: disable=no-self-use,redefined-outer-name,unused-variable,expression-not-assigned |
2
|
|
|
|
3
|
|
|
import pytest |
4
|
|
|
from expecter import expect |
|
|
|
|
5
|
|
|
|
6
|
|
|
from gitman.models import Config, load_config |
7
|
|
|
|
8
|
|
|
from .conftest import FILES |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class TestConfig: |
12
|
|
|
|
13
|
|
|
def test_init_defaults(self): |
14
|
|
|
"""Verify a configuration has a default filename and location.""" |
15
|
|
|
config = Config('mock/root') |
16
|
|
|
|
17
|
|
|
assert 'mock/root' == config.root |
18
|
|
|
assert 'gitman.yml' == config.filename |
19
|
|
|
assert 'gdm_sources' == config.location |
20
|
|
|
assert [] == config.sources |
21
|
|
|
|
22
|
|
|
def test_init_filename(self): |
23
|
|
|
"""Verify the filename can be customized.""" |
24
|
|
|
config = Config('mock/root', 'mock.custom') |
25
|
|
|
|
26
|
|
|
assert 'mock.custom' == config.filename |
27
|
|
|
assert 'gdm_sources' == config.location |
28
|
|
|
|
29
|
|
|
def test_init_location(self): |
30
|
|
|
"""Verify the location can be customized.""" |
31
|
|
|
config = Config('mock/root', location='.gitman') |
32
|
|
|
|
33
|
|
|
assert 'gitman.yml' == config.filename |
34
|
|
|
assert '.gitman' == config.location |
35
|
|
|
|
36
|
|
|
def test_path(self): |
37
|
|
|
"""Verify a configuration's path is correct.""" |
38
|
|
|
config = Config('mock/root') |
39
|
|
|
|
40
|
|
|
assert "mock/root/gitman.yml" == config.path |
41
|
|
|
|
42
|
|
|
@pytest.mark.integration |
43
|
|
|
def test_install_and_list(self): |
44
|
|
|
"""Verify the correct dependencies are installed.""" |
45
|
|
|
config = Config(FILES) |
46
|
|
|
|
47
|
|
|
count = config.install_deps() |
48
|
|
|
assert 7 == count |
49
|
|
|
|
50
|
|
|
deps = list(config.get_deps()) |
51
|
|
|
assert 7 == len(deps) |
52
|
|
|
assert 'eb37743011a398b208dd9f9ef79a408c0fc10d48' == deps[0][2] |
53
|
|
|
assert 'ddbe17ef173538d1fda29bd99a14bab3c5d86e78' == deps[1][2] |
54
|
|
|
assert 'fb693447579235391a45ca170959b5583c5042d8' == deps[2][2] |
55
|
|
|
# master branch always changes --------------------- deps[3][2] |
56
|
|
|
# master branch always changes --------------------- deps[4][2] |
57
|
|
|
assert '7bd138fe7359561a8c2ff9d195dff238794ccc04' == deps[5][2] |
58
|
|
|
assert '2da24fca34af3748e3cab61db81a2ae8b35aec94' == deps[6][2] |
59
|
|
|
|
60
|
|
|
assert 5 == len(list(config.get_deps(depth=2))) |
61
|
|
|
|
62
|
|
|
assert 3 == len(list(config.get_deps(depth=1))) |
63
|
|
|
|
64
|
|
|
assert 0 == len(list(config.get_deps(depth=0))) |
65
|
|
|
|
66
|
|
|
@pytest.mark.integration |
67
|
|
|
def test_install_with_dirs(self): |
68
|
|
|
"""Verify the dependency list can be filtered.""" |
69
|
|
|
config = Config(FILES) |
70
|
|
|
|
71
|
|
|
count = config.install_deps('gitman_2', 'gitman_3') |
72
|
|
|
assert 2 == count |
73
|
|
|
|
74
|
|
|
def test_install_with_dirs_unknown(self): |
75
|
|
|
"""Verify zero dependencies are installed with an unknown dependency.""" |
76
|
|
|
config = Config(FILES) |
77
|
|
|
|
78
|
|
|
count = config.install_deps('foobar') |
79
|
|
|
assert 0 == count |
80
|
|
|
|
81
|
|
|
def test_install_with_depth_0(self): |
82
|
|
|
"""Verify an install depth of 0 installs nothing.""" |
83
|
|
|
config = Config(FILES) |
84
|
|
|
|
85
|
|
|
count = config.install_deps(depth=0) |
86
|
|
|
assert 0 == count |
87
|
|
|
|
88
|
|
|
@pytest.mark.integration |
89
|
|
|
def test_install_with_depth_1(self): |
90
|
|
|
"""Verify an install depth of 1 installs the direct dependencies.""" |
91
|
|
|
config = Config(FILES) |
92
|
|
|
|
93
|
|
|
count = config.install_deps(depth=1) |
94
|
|
|
assert 3 == count |
95
|
|
|
|
96
|
|
|
@pytest.mark.integration |
97
|
|
|
def test_install_with_depth_2(self): |
98
|
|
|
"""Verify an install depth of 2 installs 1 level of nesting.""" |
99
|
|
|
config = Config(FILES) |
100
|
|
|
|
101
|
|
|
count = config.install_deps(depth=2) |
102
|
|
|
assert 5 == count |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
def describe_config(): |
106
|
|
|
|
107
|
|
|
@pytest.fixture |
108
|
|
|
def config(): |
109
|
|
|
return Config('m/root', 'm.ext', 'm/location') |
110
|
|
|
|
111
|
|
|
def describe_get_path(): |
112
|
|
|
|
113
|
|
|
def it_defaults_to_sources_location(config): |
114
|
|
|
expect(config.get_path()) == "m/root/m/location" |
115
|
|
|
|
116
|
|
|
def it_can_get_the_config_path(config): |
117
|
|
|
expect(config.get_path('__config__')) == "m/root/m.ext" |
118
|
|
|
|
119
|
|
|
def it_can_get_log_path(config): |
120
|
|
|
expect(config.get_path('__log__')) == "m/root/m/location/gitman.log" |
121
|
|
|
|
122
|
|
|
def it_can_get_dependency_path(config): |
123
|
|
|
expect(config.get_path('foobar')) == "m/root/m/location/foobar" |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
class TestLoad: |
127
|
|
|
|
128
|
|
|
def test_load_from_directory_with_config_file(self): |
129
|
|
|
config = load_config(FILES) |
130
|
|
|
|
131
|
|
|
assert None is not config |
132
|
|
|
|
133
|
|
|
def test_load_from_directory_without_config_file(self, tmpdir): |
134
|
|
|
tmpdir.chdir() |
135
|
|
|
|
136
|
|
|
config = load_config() |
137
|
|
|
|
138
|
|
|
assert None is config |
139
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.