Skip to content

Commit

Permalink
add inline-snapshots for pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
grillazz committed Apr 17, 2024
1 parent 6e5c357 commit 6ee787e
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ down: ## Reset project containers with compose
test: ## Run project tests
docker-compose run --rm web pytest -vv

.PHONY: test-snapshot
test-snapshot: ## Run project tests
docker-compose run --rm web pytest -vv --inline-snapshot=create

.PHONY: mypy
mypy: ## mypy check.
mypy --ignore-missing-imports .
Expand Down
167 changes: 166 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rich = "^13.7.1"
uvloop = "^0.19.0"
httptools = "^0.6.1"
ruff = "^0.3.7"
inline-snapshot = "^0.8.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
19 changes: 19 additions & 0 deletions tests/test_routers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import pytest
from fastapi import status
from httpx import AsyncClient
from inline_snapshot import snapshot


@pytest.mark.anyio
async def test_health_check(client: AsyncClient):
response = await client.get("/health-check")
assert response.status_code == status.HTTP_200_OK
assert response.json()["version"] == "7.0.8"


@pytest.mark.anyio
async def test_health_check_snapshot(client: AsyncClient):
response = await client.get("/health-check")
assert response.status_code == status.HTTP_200_OK
assert response.json() == snapshot({
"version": "7.0.8",
"databases": ["admin", "config", "farmland", "local"],
"collections": {
"admin": ["system.users", "system.version"],
"config": ["system.sessions"],
"farmland": ["greens"],
"local": ["startup_log"],
},
})


0 comments on commit 6ee787e

Please sign in to comment.