-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ Flask-JWT-Extended==4.6.0 | |
pyotp==2.9.0 | ||
qrcode==7.4.2 | ||
pypng==0.20220715.0 | ||
pika==1.3.2 | ||
pika==1.3.2 | ||
pytest==8.2.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import sys | ||
import os | ||
import pytest | ||
|
||
# Adiciona o diretório 'backend' ao caminho de importação do Python | ||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
from log_config import setup_test_logging | ||
|
||
@pytest.fixture(autouse=True) | ||
def log_tests(request): | ||
# Configuração do logger | ||
logger = setup_test_logging() | ||
|
||
logger.info(f"Starting test: {request.node.name}") | ||
yield | ||
logger.info(f"Finished test: {request.node.name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
import logging | ||
from app import create_app | ||
|
||
# Usar o logger de teste configurado | ||
logger = logging.getLogger('test') | ||
|
||
@pytest.fixture | ||
def app(): | ||
app = create_app() | ||
app.config.update({ | ||
"TESTING": True, | ||
}) | ||
return app | ||
|
||
@pytest.fixture | ||
def client(app): | ||
return app.test_client() | ||
|
||
def test_register_route(client): | ||
logger.info("Testing register route") | ||
|
||
response = client.post('/api/register', json={ | ||
'username': 'newuser', | ||
'password': 'Newpassword33@', | ||
'email': '[email protected]' | ||
}) | ||
|
||
assert response.status_code == 200, f"Expected status code 200 but got {response.status_code}" | ||
logger.info("Register route test passed") | ||
|
||
|
||
def test_login_route(client): | ||
logger.info("Testing login route") | ||
|
||
response = client.post('/api/login', json={ | ||
'email': '[email protected]', | ||
'password': 'Newpassword33@' | ||
}) | ||
|
||
assert response.status_code == 200, f"Expected status code 200 but got {response.status_code}" | ||
logger.info("Login route test passed") |