Skip to content

Commit

Permalink
Add tests for calling invalid/unknown plans
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed May 24, 2023
1 parent 620fd98 commit effbc4f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/service/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ def test_put_plan_submits_task(handler: Handler, client: TestClient) -> None:
)


def test_put_plan_with_unknown_plan_name_fails(handler: Handler, client: TestClient) -> None:
task_name = "foo"
task_params = {"detectors": ["x"]}
task_json = {"name": task_name, "params": task_params}

response = client.post("/tasks", json=task_json)

assert not handler.worker.get_pending_tasks()
assert response.status_code == status.HTTP_400_BAD_REQUEST


def test_put_plan_with_bad_params_fails(handler: Handler, client: TestClient) -> None:
task_name = "count"
task_params = {"motors": ["x"]}
task_json = {"name": task_name, "params": task_params}

response = client.post("/tasks", json=task_json)

assert not handler.worker.get_pending_tasks()
assert response.status_code == status.HTTP_400_BAD_REQUEST


def test_get_state_updates(handler: Handler, client: TestClient) -> None:
assert client.get("/worker/state").text == f'"{WorkerState.IDLE.name}"'
handler.worker._on_state_change( # type: ignore
Expand Down

0 comments on commit effbc4f

Please sign in to comment.