Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarva committed Dec 19, 2016
1 parent a723c22 commit 824ef50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
6 changes: 2 additions & 4 deletions osbs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,8 @@ def put_image_stream_tag(self, tag_id, tag):
def ensure_image_stream_tag(self, stream, tag_name, tag_template,
scheduled=False):
stream_id = stream['metadata']['name']
insecure = (stream['metadata']
.get('annotations', {})
.get('openshift.io/image.insecureRepository')
== 'true')
insecure = (stream['metadata'].get('annotations', {})
.get('openshift.io/image.insecureRepository') == 'true')
repo = stream['spec']['dockerImageRepository']
tag_id = '{0}:{1}'.format(stream_id, tag_name)

Expand Down
6 changes: 2 additions & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,7 @@ def test_put_image_stream_tag(self):
.should_receive('put_image_stream_tag')
.with_args(tag_id, tag)
.once()
.and_return('eggs')
)
.and_return('eggs'))

response = osbs.put_image_stream_tag(tag_id, tag)
assert response == 'eggs'
Expand All @@ -1028,8 +1027,7 @@ def test_ensure_image_stream_tag(self):
.should_receive('ensure_image_stream_tag')
.with_args(stream, tag_name, dict, scheduled)
.once()
.and_return('eggs')
)
.and_return('eggs'))

response = osbs.ensure_image_stream_tag(stream, tag_name, scheduled)
assert response == 'eggs'
32 changes: 15 additions & 17 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def test_stream_logs(self, openshift):

(flexmock(openshift)
.should_receive('_get')
# First: timeout in response after 100s
# First: timeout in response after 100s
.and_raise(ex)
# Next: return a real response
# Next: return a real response
.and_return(response))

(flexmock(time)
Expand Down Expand Up @@ -306,18 +306,17 @@ def test_ensure_image_stream_tag(self,
def verify_image_stream_tag(*args, **kwargs):
data = json.loads(kwargs['data'])

assert (bool(data['tag']['importPolicy'].get('insecure'))
== expected_insecure)
assert (bool(data['tag']['importPolicy'].get('scheduled'))
== expected_scheduled)
assert (bool(data['tag']['importPolicy'].get('insecure')) ==
expected_insecure)
assert (bool(data['tag']['importPolicy'].get('scheduled')) ==
expected_scheduled)

# Also verify new image stream tags are created properly.
if status_code == 404:
assert data['metadata']['name'] == tag_id
assert data['tag']['name'] == tag_name
assert (data['tag']['from']['name']
== '{0}:{1}'.format(stream_repo, tag_name))

assert (data['tag']['from']['name'] ==
'{0}:{1}'.format(stream_repo, tag_name))

return HttpResponse(200, {}, json.dumps('{}'))

Expand All @@ -341,7 +340,7 @@ def verify_image_stream_tag(*args, **kwargs):

if expected_insecure != bool(existing_insecure) or \
expected_scheduled != bool(existing_scheduled):
expected_change = True
expected_change = True

elif status_code == 404:
expected_change = True
Expand All @@ -350,17 +349,15 @@ def verify_image_stream_tag(*args, **kwargs):
.should_receive("_get")
.with_args(expected_url)
.once()
.and_return(HttpResponse(status_code, {}, mock_response))
)
.and_return(HttpResponse(status_code, {}, mock_response)))

if expected_change:
(flexmock(openshift)
.should_receive("_put")
.with_args(expected_url, data=str,
headers={"Content-Type": "application/json"})
.replace_with(verify_image_stream_tag)
.once()
)
.once())

if expected_error:
with pytest.raises(OsbsResponseException):
Expand All @@ -369,6 +366,7 @@ def verify_image_stream_tag(*args, **kwargs):

else:
assert (openshift.ensure_image_stream_tag(
stream, tag_name, self._make_tag_template() ,expected_scheduled)
== expected_change)

stream,
tag_name,
self._make_tag_template(),
expected_scheduled) == expected_change)

0 comments on commit 824ef50

Please sign in to comment.