Skip to content

Commit

Permalink
Made minor improvements to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZohebShaikh committed Jan 20, 2025
1 parent 92f5800 commit ef4c710
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def env(
print("Environment is initialized")
else:
status = client.get_environment()

print(status)


Expand Down
5 changes: 4 additions & 1 deletion tests/system_tests/test_blueapi_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,7 @@ def test_delete_current_environment(client: BlueapiClient):
current_env = client.get_environment()
client.reload_environment()
new_env = client.get_environment()
assert new_env.initialized and new_env != current_env
assert (
new_env.initialized is True
and new_env.environment_id != current_env.environment_id
)
6 changes: 4 additions & 2 deletions tests/unit_tests/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ def test_reload_environment_no_timeout(
):
mock_rest.get_environment.side_effect = [ENV, ENV, ENV, NEW_ENV]
mock_time.return_value = 100.0
client.reload_environment(timeout=None)
environment = client.reload_environment(timeout=None)
assert mock_sleep.call_count == 3
assert environment == NEW_ENV


@patch("blueapi.client.client.time.time")
Expand Down Expand Up @@ -323,8 +324,9 @@ def test_reload_environment_ignores_current_environment(
NEW_ENV, # This is the new environment
]
mock_time.return_value = 100.0
client.reload_environment(timeout=None)
environment = client.reload_environment(timeout=None)
assert mock_sleep.call_count == 3
assert environment == NEW_ENV


def test_reload_environment_failure(
Expand Down
16 changes: 13 additions & 3 deletions tests/unit_tests/service/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,19 @@ def test_get_environment_idle(mock_runner: Mock, client: TestClient) -> None:


def test_delete_environment(mock_runner: Mock, client: TestClient) -> None:
# response = client.delete("/environment")
# assert response.status_code is status.HTTP_200_OK
...
environment_id = uuid.uuid4()
mock_runner.state = EnvironmentResponse(
environment_id=environment_id,
initialized=True,
error_message=None,
)
response = client.delete("/environment")
assert response.status_code is status.HTTP_200_OK
assert response.json() == {
"environment_id": str(environment_id),
"initialized": False,
"error_message": None,
}


@patch("blueapi.service.runner.Pool")
Expand Down
5 changes: 3 additions & 2 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ def test_get_env(

env = runner.invoke(main, ["controller", "env"])
assert (
env.output
== f"environment_id=UUID('{environment_id}') initialized=True error_message=None\n" # noqa: E501
env.output == f"environment_id=UUID('{environment_id}') "
"initialized=True "
"error_message=None\n"
)


Expand Down

0 comments on commit ef4c710

Please sign in to comment.