Skip to content

Commit c4e9f41

Browse files
committed
refactor: add test authentication and dependency injection to main, remove unused files and validate extra files
1 parent df8ee39 commit c4e9f41

5 files changed

Lines changed: 30 additions & 38 deletions

File tree

app/services/database/run_seeder.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/services/database/seeder.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ sqlmodel = "^0.0.24"
1818
aiosqlite = "^0.21.0"
1919
pre-commit = "^4.2.0"
2020
passlib = "^1.7.4"
21-
pyjwt = "^2.10.1"
2221
python-multipart = "^0.0.20"
22+
pyjwt = "^2.10.1"
2323

2424
[tool.poetry.group.dev.dependencies]
2525
pytest = "^8.3.2"

tests/test_auth.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
from services.database.models import Community
3+
from sqlmodel import select
4+
from sqlmodel.ext.asyncio.session import AsyncSession
5+
6+
7+
## gerar usuario para autenticação
8+
@pytest_asyncio.fixture
9+
async def community(session: AsyncSession):
10+
community = Community(username="username", email="username@test.com", password="123Asd!@#")
11+
session.add(community)
12+
await session.commit()
13+
await session.refresh(community)
14+
return community
15+
16+
17+
## chamar o endpoint de autenticação e validar resposta
18+
@pytest.mark.asyncio
19+
async def test_authentication_token_endpoint(
20+
async_client: AsyncClient, mock_headers: Mapping[str, str]
21+
):
22+
"""Test the news endpoint returns correct status and version."""
23+
response = await async_client.post("/api/authentication/token", headers=mock_headers)
24+
25+
assert response.status_code == status.HTTP_200_OK
26+
assert response.json() == {"status": "News Criada"}
27+
28+

0 commit comments

Comments
 (0)