Completed
Push — develop ( 6c75dd...cd0240 )
by Jace
05:37
created

tests.it_should_not_overwrite()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4286
cc 2
1
# pylint: disable=no-self-use,redefined-outer-name,unused-variable,unused-argument
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
import os
4
import shutil
5
from contextlib import suppress
6
import logging
7
8
import pytest
9
from yorm.test import strip
0 ignored issues
show
Configuration introduced by
The import yorm.test could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
10
11
import gdm
12
from gdm.config import Config
13
14
15
CONFIG = """
16
location: deps
17
sources:
18
- dir: gdm_1
19
  link: ''
20
  repo: https://github.com/jacebrowning/gdm-demo
21
  rev: example-branch
22
- dir: gdm_2
23
  link: ''
24
  repo: https://github.com/jacebrowning/gdm-demo
25
  rev: example-tag
26
- dir: gdm_3
27
  link: ''
28
  repo: https://github.com/jacebrowning/gdm-demo
29
  rev: 9bf18e16b956041f0267c21baad555a23237b52e
30
""".lstrip()
31
32
log = logging.getLogger(__name__)
33
34
35
@pytest.fixture
36
def config(root="/tmp/gdm-shared"):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
37
    with suppress(FileNotFoundError):
38
        shutil.rmtree(root)
39
    with suppress(FileExistsError):
40
        os.makedirs(root)
41
    os.chdir(root)
42
    log.info("Temporary directory: %s", root)
43
44
    os.system("touch .git")
45
    config = Config(root=root)
46
    config.__mapper__.text = CONFIG  # pylint: disable=no-member
47
48
    log.debug("File listing: %s", os.listdir(root))
49
50
    return config
51
52
53
def describe_install():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
54
55
    def it_should_create_missing_directories(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
56
        assert not os.path.isdir(config.location)
57
58
        assert gdm.install('gdm_1', depth=1)
59
60
        assert ['gdm_1'] == os.listdir(config.location)
61
62
    def it_should_not_modify_config(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
63
        assert gdm.install('gdm_1', depth=1)
64
65
        assert CONFIG == config.__mapper__.text
66
67
    def it_should_use_locked_sources_if_available(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
68
        config.__mapper__.text = strip("""
69
        location: deps
70
        sources:
71
        - dir: gdm_1
72
          link: ''
73
          repo: https://github.com/jacebrowning/gdm-demo
74
          rev: example-branch
75
        sources_locked:
76
        - dir: gdm_2
77
          link: ''
78
          repo: https://github.com/jacebrowning/gdm-demo
79
          rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
80
        """)
81
82
        assert gdm.install(depth=1)
83
84
        assert ['gdm_2'] == os.listdir(config.location)
85
86
    def describe_links():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
87
88
        @pytest.fixture
89
        def config_with_link(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
90
            config.__mapper__.text = strip("""
91
            location: deps
92
            sources:
93
            - dir: gdm_1
94
              link: my_link
95
              repo: https://github.com/jacebrowning/gdm-demo
96
              rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
97
            """)
98
99
            return config
100
101
        def it_should_create(config_with_link):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
102
            assert gdm.install(depth=1)
103
104
            assert 'my_link' in os.listdir()
105
106
        def it_should_not_overwrite(config_with_link):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
107
            os.system("touch my_link")
108
109
            with pytest.raises(RuntimeError):
110
                gdm.install(depth=1)
111
112
        def it_should_overwrite_with_force(config_with_link):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
113
            os.system("touch my_link")
114
115
            assert gdm.install(depth=1, force=True)
116
117
118
def describe_uninstall():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
119
120
    def it_should_delete_dependencies_when_they_exist(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
121
        gdm.install('gdm_1', depth=1)
122
        assert os.path.isdir(config.location)
123
124
        assert gdm.uninstall()
125
126
        assert not os.path.exists(config.location)
127
128
    def it_should_not_fail_when_no_dependnecies_exist(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
129
        assert not os.path.isdir(config.location)
130
131
        assert gdm.uninstall()
132
133
134
def describe_update():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
135
136
    def it_should_not_modify_config(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
137
        gdm.update('gdm_1', depth=1)
138
139
        assert CONFIG == config.__mapper__.text
140
141
    def it_should_lock_previously_locked_dependnecies(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
142
        config.__mapper__.text = strip("""
143
        location: deps
144
        sources:
145
        - dir: gdm_1
146
          link: ''
147
          repo: https://github.com/jacebrowning/gdm-demo
148
          rev: example-branch
149
        - dir: gdm_2
150
          link: ''
151
          repo: https://github.com/jacebrowning/gdm-demo
152
          rev: example-tag
153
        sources_locked:
154
        - dir: gdm_2
155
          link: ''
156
          repo: https://github.com/jacebrowning/gdm-demo
157
          rev: (old revision)
158
        """)
159
160
        gdm.update(depth=1)
161
162
        assert strip("""
163
        location: deps
164
        sources:
165
        - dir: gdm_1
166
          link: ''
167
          repo: https://github.com/jacebrowning/gdm-demo
168
          rev: example-branch
169
        - dir: gdm_2
170
          link: ''
171
          repo: https://github.com/jacebrowning/gdm-demo
172
          rev: example-tag
173
        sources_locked:
174
        - dir: gdm_2
175
          link: ''
176
          repo: https://github.com/jacebrowning/gdm-demo
177
          rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
178
        """) == config.__mapper__.text
179
180
    def it_should_not_lock_dependnecies_when_disabled(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
181
        config.__mapper__.text = strip("""
182
        location: deps
183
        sources:
184
        - dir: gdm_1
185
          link: ''
186
          repo: https://github.com/jacebrowning/gdm-demo
187
          rev: example-branch
188
        - dir: gdm_2
189
          link: ''
190
          repo: https://github.com/jacebrowning/gdm-demo
191
          rev: example-tag
192
        sources_locked:
193
        - dir: gdm_2
194
          link: ''
195
          repo: https://github.com/jacebrowning/gdm-demo
196
          rev: (old revision)
197
        """)
198
199
        gdm.update(depth=1, lock=False)
200
201
        assert strip("""
202
        location: deps
203
        sources:
204
        - dir: gdm_1
205
          link: ''
206
          repo: https://github.com/jacebrowning/gdm-demo
207
          rev: example-branch
208
        - dir: gdm_2
209
          link: ''
210
          repo: https://github.com/jacebrowning/gdm-demo
211
          rev: example-tag
212
        sources_locked:
213
        - dir: gdm_2
214
          link: ''
215
          repo: https://github.com/jacebrowning/gdm-demo
216
          rev: (old revision)
217
        """) == config.__mapper__.text
218
219
    def it_should_lock_all_when_enabled(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
220
        gdm.update(depth=1, lock=True)
221
222
        assert CONFIG + strip("""
223
        sources_locked:
224
        - dir: gdm_1
225
          link: ''
226
          repo: https://github.com/jacebrowning/gdm-demo
227
          rev: eb37743011a398b208dd9f9ef79a408c0fc10d48
228
        - dir: gdm_2
229
          link: ''
230
          repo: https://github.com/jacebrowning/gdm-demo
231
          rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
232
        - dir: gdm_3
233
          link: ''
234
          repo: https://github.com/jacebrowning/gdm-demo
235
          rev: 9bf18e16b956041f0267c21baad555a23237b52e
236
        """) == config.__mapper__.text
237
238
239
def describe_lock():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
240
241
    def it_should_record_all_versions_when_no_arguments(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
242
        assert gdm.update(depth=1, lock=False)
243
        assert gdm.lock()
244
245
        assert CONFIG + strip("""
246
        sources_locked:
247
        - dir: gdm_1
248
          link: ''
249
          repo: https://github.com/jacebrowning/gdm-demo
250
          rev: eb37743011a398b208dd9f9ef79a408c0fc10d48
251
        - dir: gdm_2
252
          link: ''
253
          repo: https://github.com/jacebrowning/gdm-demo
254
          rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
255
        - dir: gdm_3
256
          link: ''
257
          repo: https://github.com/jacebrowning/gdm-demo
258
          rev: 9bf18e16b956041f0267c21baad555a23237b52e
259
        """) == config.__mapper__.text
260
261
    def it_should_record_specified_dependencies(config):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
262
        assert gdm.update(depth=1, lock=False)
263
        assert gdm.lock('gdm_1', 'gdm_3')
264
265
        assert CONFIG + strip("""
266
        sources_locked:
267
        - dir: gdm_1
268
          link: ''
269
          repo: https://github.com/jacebrowning/gdm-demo
270
          rev: eb37743011a398b208dd9f9ef79a408c0fc10d48
271
        - dir: gdm_3
272
          link: ''
273
          repo: https://github.com/jacebrowning/gdm-demo
274
          rev: 9bf18e16b956041f0267c21baad555a23237b52e
275
        """) == config.__mapper__.text
276