Skip to content

Commit 89c1ddf

Browse files
committed
Whitespace/isort fixes
1 parent 1a7a93b commit 89c1ddf

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

src/labthings/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def preprocess(self, data, **_):
8383

8484
class ActionSchema(Schema):
8585
"""Represents a running or completed Action
86-
86+
8787
Actions can run in the background, started by one request
8888
and subsequently polled for updates. This schema represents
8989
one Action."""

src/labthings/views/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from flask import request
66
from flask.views import MethodView
77
from typing_extensions import Protocol
8-
from werkzeug.wrappers import Response as ResponseBase
98
from werkzeug.exceptions import HTTPException
9+
from werkzeug.wrappers import Response as ResponseBase
1010

1111
from ..actions.pool import Pool
1212
from ..deque import Deque

tests/conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,26 +211,30 @@ def post(self, args):
211211
pass
212212

213213
thing.add_view(TestFieldProperty, "/TestFieldProperty")
214-
214+
215215
class FailAction(ActionView):
216216
wait_for = 1.0
217+
217218
def post(self):
218219
raise Exception("This action is meant to fail with an Exception")
219-
220+
220221
thing.add_view(FailAction, "/FailAction")
221222

222223
class AbortAction(ActionView):
223224
wait_for = 1.0
225+
224226
def post(self):
225227
abort(418, "I'm a teapot! This action should abort with an HTTP code 418")
226-
228+
227229
thing.add_view(AbortAction, "/AbortAction")
228230

229231
class ActionWithValidation(ActionView):
230232
wait_for = 1.0
231233
args = {"test_arg": fields.String(validate=validate.OneOf(["one", "two"]))}
234+
232235
def post(self):
233236
return True
237+
234238
thing.add_view(ActionWithValidation, "/ActionWithValidation")
235239

236240
return thing

tests/test_action_api.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
1-
import pytest
2-
import time
31
import json
2+
import time
3+
4+
import pytest
45

56
from labthings import LabThing
67
from labthings.views import ActionView
78

9+
810
@pytest.mark.filterwarnings("ignore:Exception in thread")
911
def test_action_exception_handling(thing_with_some_views, client):
1012
"""Check errors in an Action are handled correctly
1113
12-
14+
1315
1416
`/FieldProperty` has a validation constraint - it
1517
should return a "bad response" error if invoked with
16-
anything other than
18+
anything other than
1719
"""
18-
# `/FailAction` raises an `Exception`.
19-
# This ought to return a 201 code representing the
20-
# action that was successfully started - but should
20+
# `/FailAction` raises an `Exception`.
21+
# This ought to return a 201 code representing the
22+
# action that was successfully started - but should
2123
# show that it failed through the "status" field.
2224

2325
# This is correct for the current (24/7/2021) behaviour
24-
# but may want to change for the next version, e.g.
26+
# but may want to change for the next version, e.g.
2527
# returning a 500 code. For further discussion...
2628
r = client.post("/FailAction")
2729
assert r.status_code == 201
2830
action = r.get_json()
2931
assert action["status"] == "error"
3032

33+
3134
def test_action_abort_and_validation(thing_with_some_views, client):
3235
"""Check HTTPExceptions result in error codes.
33-
36+
3437
Subclasses of HTTPError should result in a non-200 return code, not
3538
just failures. This covers Marshmallow validation (400) and
3639
use of `abort()`.
3740
"""
3841
# `/AbortAction` should return a 418 error code
3942
r = client.post("/AbortAction")
4043
assert r.status_code == 418
41-
44+
45+
4246
def test_action_validate(thing_with_some_views, client):
4347
# `/ActionWithValidation` should fail with a 400 error
4448
# if `test_arg` is not either `one` or `two`
45-
r = client.post("/ActionWithValidation", data=json.dumps({"test_arg":"one"}))
49+
r = client.post("/ActionWithValidation", data=json.dumps({"test_arg": "one"}))
4650
assert r.status_code in [200, 201]
47-
r = client.post("/ActionWithValidation", data=json.dumps({"test_arg":"three"}))
51+
r = client.post("/ActionWithValidation", data=json.dumps({"test_arg": "three"}))
4852
assert r.status_code in [422]
49-
50-

tests/test_openapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
from labthings.apispec import utilities
1717
from labthings.extensions import BaseExtension
1818
from labthings.schema import LogRecordSchema, Schema
19-
from labthings.views import ActionView, EventView, PropertyView
2019
from labthings.utilities import get_by_path
20+
from labthings.views import ActionView, EventView, PropertyView
2121

2222

2323
def test_openapi(thing_with_some_views):

0 commit comments

Comments
 (0)