Skip to content

Commit

Permalink
chore(deps): update dependency pytest to v8 (#375)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency pytest to v8

* fix: metric tests

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Pat Heard <[email protected]>
  • Loading branch information
renovate[bot] and patheard authored Mar 8, 2024
1 parent 27a9538 commit 0ebf913
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ coverage==7.4.3
flake8==7.0.0
httpx==0.27.0
locust==2.23.1
pytest==7.4.4
pytest==8.0.2
requests==2.31.0
uvicorn==0.27.1
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
12 changes: 10 additions & 2 deletions api/tests/api_gateway/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,17 @@ def test_metrics(mock_mangum, context_fixture, capsys, metrics):
mock_mangum.return_value = mock_asgi_handler
main.handler({"httpMethod": "GET"}, context_fixture)

log = capsys.readouterr().out.strip()
logs = capsys.readouterr().out.strip().split("\n")

metrics_output = json.loads(log)
assert len(logs) == 2
metrics_startup = json.loads(logs[0])
metrics_output = json.loads(logs[1])

assert (
"ColdStart"
in metrics_startup["_aws"]["CloudWatchMetrics"][0]["Metrics"][0]["Name"]
)
assert metrics_startup["function_name"] == "api"

metric_list = [
"ListCreated",
Expand Down
8 changes: 0 additions & 8 deletions api/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import main
import json
from unittest.mock import MagicMock, patch


Expand All @@ -12,14 +11,7 @@ def test_handler_api_gateway_event(mock_mangum, context_fixture, capsys):
mock_asgi_handler.assert_called_once_with({"httpMethod": "GET"}, context_fixture)

log = capsys.readouterr().out.strip()
metrics_output = json.loads(log)

assert "ListManager" in log
assert (
"ColdStart"
in metrics_output["_aws"]["CloudWatchMetrics"][0]["Metrics"][0]["Name"]
)
assert metrics_output["function_name"] == "api"


@patch("main.log")
Expand Down

0 comments on commit 0ebf913

Please sign in to comment.