Эндпоинты не работают
This commit is contained in:
52
tests/test_upload_endpoints.py
Normal file
52
tests/test_upload_endpoints.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
Тесты для эндпоинтов загрузки данных
|
||||
"""
|
||||
import pytest
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class TestUploadEndpoints:
|
||||
"""Тесты эндпоинтов загрузки"""
|
||||
|
||||
def test_upload_svodka_ca(self, wait_for_api, upload_file, api_base_url):
|
||||
"""Тест загрузки файла svodka_ca.xlsx"""
|
||||
file_path = upload_file("svodka_ca.xlsx")
|
||||
|
||||
with open(file_path, 'rb') as f:
|
||||
files = {'file': ('svodka_ca.xlsx', f, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')}
|
||||
response = requests.post(f"{api_base_url}/svodka_ca/upload", files=files)
|
||||
|
||||
assert response.status_code == 200, f"Ожидался статус 200, получен {response.status_code}: {response.text}"
|
||||
|
||||
result = response.json()
|
||||
assert result["success"] is True, f"Загрузка не удалась: {result}"
|
||||
print(f"✅ svodka_ca.xlsx загружен успешно: {result['message']}")
|
||||
|
||||
def test_upload_svodka_pm_plan(self, wait_for_api, upload_file, api_base_url):
|
||||
"""Тест загрузки архива pm_plan.zip"""
|
||||
file_path = upload_file("pm_plan.zip")
|
||||
|
||||
with open(file_path, 'rb') as f:
|
||||
files = {'zip_file': ('pm_plan.zip', f, 'application/zip')}
|
||||
response = requests.post(f"{api_base_url}/svodka_pm/upload-zip", files=files)
|
||||
|
||||
assert response.status_code == 200, f"Ожидался статус 200, получен {response.status_code}: {response.text}"
|
||||
|
||||
result = response.json()
|
||||
assert result["success"] is True, f"Загрузка не удалась: {result}"
|
||||
print(f"✅ pm_plan.zip загружен успешно: {result['message']}")
|
||||
|
||||
def test_upload_monitoring_fuel(self, wait_for_api, upload_file, api_base_url):
|
||||
"""Тест загрузки архива monitoring.zip"""
|
||||
file_path = upload_file("monitoring.zip")
|
||||
|
||||
with open(file_path, 'rb') as f:
|
||||
files = {'zip_file': ('monitoring.zip', f, 'application/zip')}
|
||||
response = requests.post(f"{api_base_url}/monitoring_fuel/upload-zip", files=files)
|
||||
|
||||
assert response.status_code == 200, f"Ожидался статус 200, получен {response.status_code}: {response.text}"
|
||||
|
||||
result = response.json()
|
||||
assert result["success"] is True, f"Загрузка не удалась: {result}"
|
||||
print(f"✅ monitoring.zip загружен успешно: {result['message']}")
|
||||
Reference in New Issue
Block a user