Skip to content

Commit

Permalink
error with patching sleepy test
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Apr 3, 2024
1 parent aea431a commit 36fec54
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,33 @@ def test_reset_env(
"DELETE",
"http://localhost:8000/environment",
)


@pytest.mark.handler
@patch("blueapi.service.handler.Handler")
@patch("requests.request")
def test_reset_env2(
mock_requests: Mock,
mock_handler: Mock,
handler: Handler,
client: TestClient,
runner: CliRunner,
):
# Mock the sleep function to avoid actual delays in the test
with patch("time.sleep", return_value=None):
with patch("uvicorn.run", side_effect=None):
result = runner.invoke(main, ["serve"])

assert result.exit_code == 0

mock_requests.return_value = Mock()

# Invoke the CLI command that would trigger the environment initialization check
runner.invoke(main, ["controller", "env", "-r"])

# Check if the DELETE request was made correctly
assert mock_requests.call_args[0] == (
"DELETE",
"http://localhost:8000/environment",
)

0 comments on commit 36fec54

Please sign in to comment.