Skip to content

Commit adab40c

Browse files
committed
fix tests
1 parent da8a616 commit adab40c

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ help: ## Show this help
44

55
.PHONY: build
66
build: ## Build project with compose
7-
docker-compose build
7+
docker compose build
88

99
.PHONY: up
1010
up: ## Run project with compose
11-
docker-compose up
11+
docker compose up
1212

1313
.PHONY: down
1414
down: ## Reset project containers with compose
15-
docker-compose down -v --remove-orphans
15+
docker compose down -v --remove-orphans
1616

1717
.PHONY: test
1818
test: ## Run project tests
19-
docker-compose run --rm web pytest -vv tests
19+
docker compose -f compose.yml run --rm web pytest -vv tests
2020

2121
.PHONY: test-snapshot
2222
test-snapshot: ## Run project tests
23-
docker-compose run --rm web pytest -vv --inline-snapshot=create
23+
docker compose -f compose.yml run web pytest --inline-snapshot=create tests
2424

2525
.PHONY: mypy
2626
mypy: ## mypy check.
@@ -41,5 +41,5 @@ format: ## format project code.
4141

4242
.PHONY: clean
4343
clean: ## Clean Reset project containers and volumes with compose
44-
docker-compose down -v --remove-orphans | true
45-
docker-compose rm -f
44+
docker compose down -v --remove-orphans | true
45+
docker compose rm -f

docker-compose.yml renamed to compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
"
1212
volumes:
1313
- ./greens:/app/greens
14+
- ./tests:/app/tests
1415
ports:
1516
- "8989:8989"
1617
depends_on:

tests/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import AsyncGenerator
22

33
import pytest
4-
from httpx import AsyncClient
4+
from httpx import AsyncClient, ASGITransport
55

66
from greens.config import settings as global_settings
77
from greens.main import app, init_mongo
@@ -18,10 +18,13 @@ def anyio_backend(request):
1818

1919

2020
@pytest.fixture
21-
async def client() -> AsyncGenerator:
21+
async def client() -> AsyncGenerator[AsyncClient]:
22+
transport = ASGITransport(
23+
app=app,
24+
)
2225
async with AsyncClient(
23-
app=app,
2426
base_url="http://testserver",
27+
transport=transport,
2528
) as client:
2629
app.state.logger = get_logger(__name__)
2730
app.state.mongo_client, app.state.mongo_db, app.state.mongo_collection = (

0 commit comments

Comments
 (0)