init commit

This commit is contained in:
prod-tech
2024-11-17 02:31:42 +03:00
commit cf933c770c
217 changed files with 19340 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
import pytest
@pytest.fixture
def auth_token():
pass
+41
View File
@@ -0,0 +1,41 @@
from fastapi.testclient import TestClient
import sqlmodel
from app.api.events.routers import events_router
import app.core.db
from app.models.event import Event
from app.tests.api.mockdata import auth_client
from app.tests.api.mockdata import telegram_init_data
client = TestClient(events_router)
def test_events() -> None:
auth_response = auth_client.post('/token', json=telegram_init_data)
assert auth_response.status_code == 200, 'Failed to authenticate'
token = auth_response.json().get('access_token')
assert token is not None, 'Token not found in response'
headers = {'Authorization': f'Bearer {token}'}
event_data = {'name': 'Sample Event Name'}
response = client.post('/', headers=headers, json=event_data)
response_event = response.json()
assert response.status_code == 200, 'Event creation failed'
with sqlmodel.Session(app.core.db.engine) as session:
event = session.get(Event, response_event['id'])
assert event.name == event_data['name'], 'Wrong name for event'
response = client.get(f'/{response_event["id"]}', headers=headers)
assert response.status_code == 200, 'Event info gathering failed'
response = client.get('/', headers=headers)
response_events = response.json()
assert response.status_code == 200, 'Event info getting failed'
assert response_events
+25
View File
@@ -0,0 +1,25 @@
from fastapi.testclient import TestClient
from app.api.items.routers import items_router
client = TestClient(items_router)
def test_items() -> None:
# create_transaction = auth_client.post('/token', json=telegram_init_data)
# assert auth_response.status_code == 200, 'Failed to authenticate'
#
# token = auth_response.json().get('access_token')
# assert token is not None, 'Token not found in response'
# headers = {'Authorization': f'Bearer {token}'}
event_data = [
{
'title': 'vodka',
'price': 1000,
'all_users_selected': False,
},
]
assert event_data
+28
View File
@@ -0,0 +1,28 @@
import fastapi.testclient
import app.api.auth.routers
auth_client = fastapi.testclient.TestClient(app.api.auth.routers.auth_router)
telegram_init_data = {
'query_id': '1',
'user': {
'id': 0,
'first_name': 'string',
'last_name': '1',
'username': '1',
'language_code': '1',
'is_premium': False,
'added_to_attachment_menu': False,
'allows_write_to_pm': False,
'photo_url': '1',
},
'receiver': '1',
'chat': '1',
'chat_type': '1',
'chat_instance': '1',
'start_param': '1',
'can_send_after': '1',
'auth_date': 0,
'hash': 'string',
}
@@ -0,0 +1,25 @@
from fastapi.testclient import TestClient
from app.api.transactions.routers import transactions_router
client = TestClient(transactions_router)
def test_transactions() -> None:
# create_transaction = auth_client.post('/token', json=telegram_init_data)
# assert auth_response.status_code == 200, 'Failed to authenticate'
#
# token = auth_response.json().get('access_token')
# assert token is not None, 'Token not found in response'
# headers = {'Authorization': f'Bearer {token}'}
event_data = [
{
'title': 'vodka',
'price': 1000,
'all_users_selected': False,
},
]
assert event_data
@@ -0,0 +1,11 @@
from fastapi.testclient import TestClient
from app.api.utils.routers import utils_router
client = TestClient(utils_router)
def test_read_main():
response = client.get('/health-check')
assert response.status_code == 200
assert response.json() == {'msg': 'healthy'}