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

Commit f64069a

Browse files
committed
fix tox flake8 and unit tests & docker python path
1 parent 2007934 commit f64069a

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LABEL maintainer "CSC Developers"
2121
LABEL org.label-schema.schema-version="1.0"
2222
LABEL org.label-schema.vcs-url="https://github.com/CSCFI/swift-x-account-sharing"
2323

24-
COPY --from=BACKEND /usr/local/lib/python3.7 /usr/local/lib/python3.7/
24+
COPY --from=BACKEND /usr/local/lib/python3.8 /usr/local/lib/python3.8/
2525

2626
COPY --from=BACKEND /usr/local/bin/gunicorn /usr/local/bin/
2727

swift_x_account_sharing/bindings/bind.py

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
ssl_context.load_verify_locations(certifi.where())
1717

1818

19-
2019
class SwiftXAccountSharing:
2120
"""Swift X Account Sharing backend client."""
2221

@@ -56,20 +55,23 @@ async def get_access(
5655

5756
params = sign_api_request(path)
5857

59-
async with self.session.get(url, params=params, ssl=ssl_context) as resp:
58+
async with self.session.get(url,
59+
params=params,
60+
ssl=ssl_context) as resp:
6061
if resp.status == 200:
6162
try:
6263
return json.loads(await resp.text())
6364
except json.decoder.JSONDecodeError:
64-
logging.error("Decoding JSON error response was not possible.")
65+
logging.error("Decoding JSON error \
66+
response was not possible.")
6567
raise
6668
except Exception as e:
67-
logging.error(f"Unknown exception occured with content: {e}.")
69+
logging.error(f"Unknown exception \
70+
occured with content: {e}.")
6871
raise
6972
else:
7073
logging.error(f"response status: {resp.status}.")
7174
raise Exception(f"response status: {resp.status}.")
72-
7375

7476
async def get_access_details(
7577
self,
@@ -84,15 +86,19 @@ async def get_access_details(
8486
params = sign_api_request(path)
8587
params.update({"owner": owner})
8688

87-
async with self.session.get(url, params=params, ssl=ssl_context) as resp:
89+
async with self.session.get(url,
90+
params=params,
91+
ssl=ssl_context) as resp:
8892
if resp.status == 200:
8993
try:
9094
return json.loads(await resp.text())
9195
except json.decoder.JSONDecodeError:
92-
logging.error("Decoding JSON error response was not possible.")
96+
logging.error("Decoding JSON error \
97+
response was not possible.")
9398
raise
9499
except Exception as e:
95-
logging.error(f"Unknown exception occured with content: {e}.")
100+
logging.error(f"Unknown exception \
101+
occured with content: {e}.")
96102
raise
97103
else:
98104
logging.error(f"response status: {resp.status}.")
@@ -108,15 +114,19 @@ async def get_share(
108114

109115
params = sign_api_request(path)
110116

111-
async with self.session.get(url, params=params, ssl=ssl_context) as resp:
117+
async with self.session.get(url,
118+
params=params,
119+
ssl=ssl_context) as resp:
112120
if resp.status == 200:
113121
try:
114122
return json.loads(await resp.text())
115123
except json.decoder.JSONDecodeError:
116-
logging.error("Decoding JSON error response was not possible.")
124+
logging.error("Decoding JSON error \
125+
response was not possible.")
117126
raise
118127
except Exception as e:
119-
logging.error(f"Unknown exception occured with content: {e}.")
128+
logging.error(f"Unknown exception \
129+
occured with content: {e}.")
120130
raise
121131
else:
122132
logging.error(f"response status: {resp.status}.")
@@ -133,15 +143,19 @@ async def get_share_details(
133143

134144
params = sign_api_request(path)
135145

136-
async with self.session.get(url, params=params, ssl=ssl_context) as resp:
146+
async with self.session.get(url,
147+
params=params,
148+
ssl=ssl_context) as resp:
137149
if resp.status == 200:
138150
try:
139151
return json.loads(await resp.text())
140152
except json.decoder.JSONDecodeError:
141-
logging.error("Decoding JSON error response was not possible.")
153+
logging.error("Decoding JSON error \
154+
response was not possible.")
142155
raise
143156
except Exception as e:
144-
logging.error(f"Unknown exception occured with content: {e}.")
157+
logging.error(f"Unknown exception \
158+
occured with content: {e}.")
145159
raise
146160
else:
147161
logging.error(f"response status: {resp.status}.")
@@ -167,15 +181,19 @@ async def share_new_access(
167181
"address": address
168182
})
169183

170-
async with self.session.post(url, params=params, ssl=ssl_context) as resp:
184+
async with self.session.post(url,
185+
params=params,
186+
ssl=ssl_context) as resp:
171187
if resp.status == 200:
172188
try:
173189
return json.loads(await resp.text())
174190
except json.decoder.JSONDecodeError:
175-
logging.error("Decoding JSON error response was not possible.")
191+
logging.error("Decoding JSON error \
192+
response was not possible.")
176193
raise
177194
except Exception as e:
178-
logging.error(f"Unknown exception occured with content: {e}.")
195+
logging.error(f"Unknown exception \
196+
occured with content: {e}.")
179197
raise
180198
else:
181199
logging.error(f"response status: {resp.status}.")
@@ -198,15 +216,19 @@ async def share_edit_access(
198216
"access": self.parse_list_to_string(accesslist),
199217
})
200218

201-
async with self.session.patch(url, params=params, ssl=ssl_context) as resp:
219+
async with self.session.patch(url,
220+
params=params,
221+
ssl=ssl_context) as resp:
202222
if resp.status == 200:
203223
try:
204224
return json.loads(await resp.text())
205225
except json.decoder.JSONDecodeError:
206-
logging.error("Decoding JSON error response was not possible.")
226+
logging.error("Decoding JSON error \
227+
response was not possible.")
207228
raise
208229
except Exception as e:
209-
logging.error(f"Unknown exception occured with content: {e}.")
230+
logging.error(f"Unknown exception \
231+
occured with content: {e}.")
210232
raise
211233
else:
212234
logging.error(f"response status: {resp.status}.")
@@ -227,5 +249,7 @@ async def share_delete_access(
227249
"user": self.parse_list_to_string(userlist),
228250
})
229251

230-
async with self.session.delete(url, params=params, ssl=ssl_context) as resp:
252+
async with self.session.delete(url,
253+
params=params,
254+
ssl=ssl_context) as resp:
231255
return bool(resp.status == 204)

tests/test_bindings_bind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):
2020
"text": asynctest.CoroutineMock(
2121
return_value="[]"
2222
),
23-
"status": 204
23+
"status": 200
2424
})
2525

2626
async def __aenter__(self, *args, **kwargs):

0 commit comments

Comments
 (0)