Skip to content

Commit cd85859

Browse files
author
Joel Collins
committed
Removed tests for deprecated code
1 parent cac9add commit cd85859

11 files changed

+39
-442
lines changed

src/labthings/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def description_from_view(view_class):
8181
summary = get_summary(view_class)
8282

8383
methods = []
84-
for method_key in http_method_funcs:
84+
for method_key in ("get", "post", "put"):
8585
if hasattr(view_class, method_key):
8686
methods.append(method_key.upper())
8787

tests/conftest.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from labthings import LabThing
1414
from labthings.actions import Pool
1515
from labthings.json import encode_json
16-
from labthings.views import View
16+
from labthings.views import View, ActionView, PropertyView
1717

1818

1919
class Helpers:
@@ -190,6 +190,27 @@ def delete(self):
190190
return ViewClass
191191

192192

193+
@pytest.fixture
194+
def action_view_cls():
195+
class ActionViewClass(ActionView):
196+
def post(self):
197+
return "POST"
198+
199+
return ActionViewClass
200+
201+
202+
@pytest.fixture
203+
def property_view_cls():
204+
class PropertyViewClass(PropertyView):
205+
def get(self):
206+
return "GET"
207+
208+
def put(self):
209+
return "PUT"
210+
211+
return PropertyViewClass
212+
213+
193214
@pytest.fixture
194215
def spec():
195216
return APISpec(

tests/test_apispec_apispec.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/test_apispec_converter.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/test_apispec_utilities.py

Lines changed: 0 additions & 143 deletions
This file was deleted.

tests/test_default_views.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -91,60 +91,3 @@ def task_func():
9191
def test_action_kill_missing(thing_client):
9292
with thing_client as c:
9393
assert c.delete("/actions/missing_id").status_code == 404
94-
95-
96-
### DEPRECATED: LEGACY TASK VIEW
97-
98-
99-
def test_tasks_list(thing_client):
100-
def task_func():
101-
pass
102-
103-
task_obj = current_labthing().actions.spawn(task_func)
104-
105-
with thing_client as c:
106-
response = c.get("/tasks").json
107-
ids = [task.get("id") for task in response]
108-
assert str(task_obj.id) in ids
109-
110-
111-
def test_task_representation(thing_client):
112-
def task_func():
113-
pass
114-
115-
task_obj = current_labthing().actions.spawn(task_func)
116-
task_id = str(task_obj.id)
117-
118-
with thing_client as c:
119-
response = c.get(f"/tasks/{task_id}").json
120-
assert response
121-
122-
123-
def test_task_representation_missing(thing_client):
124-
with thing_client as c:
125-
assert c.get("/tasks/missing_id").status_code == 404
126-
127-
128-
def test_task_kill(thing_client):
129-
def task_func():
130-
while not current_action().stopping:
131-
time.sleep(0)
132-
133-
task_obj = current_labthing().actions.spawn(task_func)
134-
task_id = str(task_obj.id)
135-
136-
# Wait for task to start
137-
task_obj.started.wait()
138-
assert task_id in current_labthing().actions.to_dict()
139-
140-
# Send a DELETE request to terminate the task
141-
with thing_client as c:
142-
response = c.delete(f"/tasks/{task_id}")
143-
assert response.status_code == 200
144-
# Test task was stopped
145-
assert task_obj._status == "stopped"
146-
147-
148-
def test_task_kill_missing(thing_client):
149-
with thing_client as c:
150-
assert c.delete("/tasks/missing_id").status_code == 404

tests/test_labthing.py

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ def test_init_types():
1313
assert thing.types == types
1414

1515

16-
def test_init_types_invalid():
17-
types = ["org;labthings;test"]
18-
with pytest.raises(ValueError):
19-
LabThing(types=types)
20-
21-
2216
def test_init_app(app):
2317
thing = LabThing()
2418
thing.init_app(app)
@@ -59,16 +53,16 @@ def get(self):
5953
assert c.get("/index").data == b'"GET"\n'
6054

6155

62-
def test_add_view_action(thing, view_cls, client):
63-
view_cls.tags = ["actions"]
64-
thing.add_view(view_cls, "/index", endpoint="index")
65-
assert view_cls in thing._action_views.values()
56+
def test_add_view_action(thing, action_view_cls, client):
57+
action_view_cls.tags = ["actions"]
58+
thing.add_view(action_view_cls, "/index", endpoint="index")
59+
assert action_view_cls in thing._action_views.values()
6660

6761

68-
def test_add_view_property(thing, view_cls, client):
69-
view_cls.tags = ["properties"]
70-
thing.add_view(view_cls, "/index", endpoint="index")
71-
assert view_cls in thing._property_views.values()
62+
def test_add_view_property(thing, property_view_cls, client):
63+
property_view_cls.tags = ["properties"]
64+
thing.add_view(property_view_cls, "/index", endpoint="index")
65+
assert property_view_cls in thing._property_views.values()
7266

7367

7468
def test_init_app_early_views(app, view_cls, client):
@@ -239,24 +233,3 @@ def test_version(thing):
239233
thing.version = "x.x.x"
240234
assert thing.version == "x.x.x"
241235
assert thing.spec.version == "x.x.x"
242-
243-
244-
def test_build_property(thing):
245-
obj = type("obj", (object,), {"property_name": "propertyValue"})
246-
247-
thing.build_property(obj, "property_name")
248-
# -1 index for last view added
249-
# 1 index for URL tuple
250-
assert "/properties/type/property_name" in thing.views[-1][1]
251-
252-
253-
def test_build_action(thing):
254-
def f():
255-
return "response"
256-
257-
obj = type("obj", (object,), {"f": f})
258-
259-
thing.build_action(obj, "f")
260-
# -1 index for last view added
261-
# 1 index for URL tuple
262-
assert "/actions/type/f" in thing.views[-1][1]

0 commit comments

Comments
 (0)