Skip to content

Commit fd67f1e

Browse files
Merge pull request #9 from C216-Distribuid-System-Project/test/MF-route_register
Initial Tests and Authentication Route Coverage
2 parents c00601b + 303be63 commit fd67f1e

File tree

18 files changed

+144
-26
lines changed

18 files changed

+144
-26
lines changed

docker/API/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ COPY . .
1010
RUN pip install --no-cache-dir -r requirements.txt
1111

1212
# Default command to run the API
13-
CMD ["python", "src/main.py"]
13+
CMD ["python", "-m", "src.main"]

docker/docker-compose.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
mysql:
53
build:
@@ -16,6 +14,22 @@ services:
1614
- "3307:3306"
1715
volumes:
1816
- mysql_data:/var/lib/mysql
17+
18+
mysql-test:
19+
build:
20+
context: ..
21+
dockerfile: docker/MySQL/dockerfile
22+
image: todolist-mysql
23+
container_name: todolist-mysql-test
24+
environment:
25+
MYSQL_ROOT_PASSWORD: root_pass
26+
MYSQL_DATABASE: todolist
27+
MYSQL_USER: app_test
28+
MYSQL_PASSWORD: app_pass_test
29+
ports:
30+
- "3308:3306"
31+
volumes:
32+
- mysql_data_test:/var/lib/mysql
1933

2034
api:
2135
build:
@@ -32,3 +46,4 @@ services:
3246

3347
volumes:
3448
mysql_data:
49+
mysql_data_test:

docs/pt-br/api_docker_documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ O arquivo [`docker/API/dockerfile`](../../docker/API/dockerfile) é responsável
3232

3333
5. **Comando para rodar a API**
3434
```dockerfile
35-
CMD ["python", "src/main.py"]
35+
CMD ["python", "-m", "src.main"]
3636
```
3737
Inicia a API utilizando o arquivo `src/main.py`.
3838

requirements.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
annotated-types==0.7.0
22
anyio==4.10.0
3-
bcrypt==4.3.0
3+
bcrypt==4.0.1
44
certifi==2025.8.3
55
cffi==2.0.0
66
click==8.1.8
@@ -19,18 +19,21 @@ httpcore==1.0.9
1919
httptools==0.6.4
2020
httpx==0.28.1
2121
idna==3.10
22+
iniconfig==2.1.0
2223
Jinja2==3.1.6
2324
jose==1.0.0
2425
markdown-it-py==3.0.0
2526
MarkupSafe==3.0.2
2627
mdurl==0.1.2
28+
packaging==25.0
2729
passlib==1.7.4
28-
pyasn1==0.6.1
30+
pluggy==1.6.0
2931
pycparser==2.23
3032
pydantic==2.11.9
3133
pydantic_core==2.33.2
3234
Pygments==2.19.2
3335
PyMySQL==1.1.2
36+
pytest==8.4.2
3437
python-dotenv==1.1.1
3538
python-jose==3.5.0
3639
python-multipart==0.0.20
@@ -45,6 +48,7 @@ six==1.17.0
4548
sniffio==1.3.1
4649
SQLAlchemy==2.0.43
4750
starlette==0.48.0
51+
tomli==2.2.1
4852
typer==0.19.1
4953
typing-inspection==0.4.1
5054
typing_extensions==4.15.0

src/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import uvicorn
22
from fastapi import FastAPI
33
from fastapi.middleware.cors import CORSMiddleware
4-
from modules.modules_api import router
4+
from src.modules.modules_api import router
55

66
# Initialize the FastAPI application
77
app = FastAPI()
@@ -21,4 +21,4 @@
2121

2222
if __name__ == "__main__":
2323
# Run the application with Uvicorn
24-
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
24+
uvicorn.run("src.main:app", host="0.0.0.0", port=8000, reload=True)

src/models/user_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from sqlalchemy import Column, Integer, String, Date, TIMESTAMP
22
from sqlalchemy.sql import func
3-
from modules.database_conection import Base
3+
from src.modules.database_conection import Base
44

55
class User(Base):
66
"""

src/modules/database_conection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import os
12
from sqlalchemy import create_engine
2-
from sqlalchemy.ext.declarative import declarative_base
33
from sqlalchemy.orm import sessionmaker
4-
import os
4+
from sqlalchemy.orm import declarative_base
55

66
"""
77
Database connection module using SQLAlchemy.

src/modules/modules_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from fastapi import APIRouter
2-
from routes.authentication_routes import authentication_router
3-
from routes.user_routes import user_router
2+
from src.routes.authentication_routes import authentication_router
3+
from src.routes.user_routes import user_router
44

55
# -------------------- API ROUTES -------------------- #
66
router = APIRouter()

src/routes/authentication_routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from utils.utils import get_db
1+
from src.utils.utils import get_db
22
from sqlalchemy.orm import Session
33
from schemas.token_schema import Token
44
from utils.security import create_access_token
5-
from schemas.users.CRUD.create import create_user
5+
from src.schemas.users.CRUD.create import create_user
66
from fastapi import APIRouter, Depends, HTTPException
7-
from schemas.users.CRUD.read import authenticate_user, get_user_by_email
8-
from schemas.users.users_schema import UserCreate, UserLogin, UserResponse
7+
from src.schemas.users.CRUD.read import authenticate_user, get_user_by_email
8+
from src.schemas.users.users_schema import UserCreate, UserLogin, UserResponse
99

1010
authentication_router = APIRouter(prefix="/auth", tags=["auth"])
1111

src/schemas/users/CRUD/create.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from sqlalchemy.orm import Session
2-
from models.user_model import User
3-
from schemas.users.users_schema import UserCreate
2+
from src.models.user_model import User
3+
from src.schemas.users.users_schema import UserCreate
44
from passlib.context import CryptContext
55

6-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
6+
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto", bcrypt__ident="2b")
77

88
def create_user(db: Session, user_data: UserCreate):
99
"""

0 commit comments

Comments
 (0)