Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit ccd0a8d

Browse files
committed
linting
1 parent 6307abd commit ccd0a8d

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

tests/backends/test_gcs.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,50 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from tfworker.backends.base import BackendError
16-
import pytest
17-
from unittest.mock import patch, call
1815
from unittest import mock
16+
from unittest.mock import call, patch
17+
18+
import pytest
19+
from tfworker.backends.base import BackendError
1920

2021

2122
class MockGCSClient:
2223
def __init__(self):
2324
self._connection = MockGCSConnection()
24-
25+
2526
@property
2627
def get_bucket(self):
2728
return MockGCSBucket
29+
30+
2831
class MockGCSConnection:
2932
@property
3033
def api_request(self):
3134
return None
3235

36+
3337
class MockGCSBucket:
3438
def __init__(self, bucket):
3539
self._blobs = [
3640
MockGCSBlob("terraform/test/foo/default.tfstate", "", b'{"resources":[]}'),
3741
MockGCSBlob("terraform/test/bar/default.tfstate", "", b'{"resources":[]}'),
38-
MockGCSBlob("terraform/fail/tflock/default.tflock", "", b'{"resources":[]}'),
42+
MockGCSBlob(
43+
"terraform/fail/tflock/default.tflock", "", b'{"resources":[]}'
44+
),
3945
MockGCSBlob("terraform/fail/other/other.file", "", b'{"resources":[]}'),
4046
]
4147

4248
with open(f"{bucket}/tests/fixtures/states/occupied.tfstate", "rb") as f:
43-
self._blobs.append(MockGCSBlob("terraform/fail/occupied/default.tfstate", "", f.read()))
44-
49+
self._blobs.append(
50+
MockGCSBlob("terraform/fail/occupied/default.tfstate", "", f.read())
51+
)
4552

4653
def list_blobs(self, prefix):
4754
blobs = list(filter(lambda x: x.name.startswith(prefix), self._blobs))
4855
assert len(blobs) > 0
4956
return blobs
57+
58+
5059
class MockGCSBlob:
5160
def __init__(self, name, path, content):
5261
self.name = name
@@ -59,6 +68,7 @@ def download_as_string(self):
5968
def delete(self):
6069
pass
6170

71+
6272
class TestClean:
6373
def test_clean_prefix_check(self, gbasec):
6474
gbasec.backend._gcs_prefix = None
@@ -102,13 +112,17 @@ def test_clean_deployment_limit(self, mock_clean, mock_iter, gbasec):
102112
with pytest.raises(BackendError):
103113
gbasec.backend._clean_deployment_limit(("zed",))
104114

105-
106115
# @todo: there is a more accurate test, but I'm unable to get it working properly
107-
gbasec.backend._clean_deployment_limit(("foo", "bar",))
116+
gbasec.backend._clean_deployment_limit(
117+
(
118+
"foo",
119+
"bar",
120+
)
121+
)
108122
assert mock_clean.call_count == 2
109123
# both methods below are failing, attempted with decorator and yeilding the mock
110124
# calls = [
111-
# call('terraform/test/foo',),
125+
# call('terraform/test/foo',),
112126
# call('terraform/test/bar',),
113127
# ]
114128
# assert mock_clean.assert_has_calls(calls)
@@ -166,7 +180,6 @@ def test_parse_gcs_items(self, gbasec, prefix, inval, outval, expected_raise):
166180
assert gbasec.backend._parse_gcs_items(inval) == outval
167181

168182

169-
170183
def test_google_hcl(gbasec):
171184
render = gbasec.backend.hcl("test")
172185
expected_render = """ backend "gcs" {

tests/util/test_copier.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from unittest.mock import patch
2020

2121
import pytest
22-
from tfworker.util.copier import Copier, CopyFactory, FileSystemCopier, GitCopier
22+
from tfworker.util.copier import (Copier, CopyFactory, FileSystemCopier,
23+
GitCopier)
2324

2425
C_CONFLICTS = ["test.txt", "foo", "test.tf"]
2526
C_SOURCE = "test_source"

tfworker/backends/gcs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from .base import BackendError, BaseBackend, validate_backend_empty
1615
import json
16+
1717
import click
18-
from google.cloud import storage
1918
from google.api_core import page_iterator
19+
from google.cloud import storage
20+
21+
from .base import BackendError, BaseBackend, validate_backend_empty
2022

2123

2224
class GCSBackend(BaseBackend):

tfworker/commands/clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# limitations under the License.
1414

1515
import click
16-
from tfworker.commands.base import BaseCommand
1716
from tfworker.backends.base import BackendError
17+
from tfworker.commands.base import BaseCommand
1818

1919

2020
class CleanCommand(BaseCommand):

0 commit comments

Comments
 (0)