You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@responses.activate
@pytest.mark.handler
@patch("blueapi.service.handler.Handler")
@patch("blueapi.cli.cli.sleep", return_value=None)
def test_env_endpoint_interaction(
mock_sleep: MagicMock, mock_handler: Mock, handler: Handler, runner: CliRunner
):
# Setup mocked responses for the REST endpoints
responses.add(
responses.DELETE,
"http://localhost:8000/environment",
status=200,
json=EnvironmentResponse(initialized=False).dict(),
)
responses.add(
responses.GET,
"http://localhost:8000/environment",
json=EnvironmentResponse(initialized=False).dict(),
status=200,
)
responses.add(
responses.GET,
"http://localhost:8000/environment",
json=EnvironmentResponse(initialized=False).dict(),
status=200,
)
responses.add(
responses.GET,
"http://localhost:8000/environment",
status=200,
json=EnvironmentResponse(initialized=True).dict(),
)
# Run the command that should interact with these endpoints
result = runner.invoke(main, ["controller", "env", "-r"])
# Check if the endpoints were hit as expected
assert len(responses.calls) == 4 # Ensures that all expected calls were made
Replacing other test logic with
responses
? It seems neaterOriginally posted by @DiamondJoseph in #409 (comment)
The text was updated successfully, but these errors were encountered: