Spaces:
Sleeping
Sleeping
Download tests/test_new_features.py from Presight-AI/app: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Presight-AI/app/resolve/main/tests/test_new_features.py
- Command line
-
hf download hf://spaces/Presight-AI/app/tests/test_new_features.py
-
curl -L -o test_new_features.py https://huggingface.co/spaces/Presight-AI/app/resolve/main/tests/test_new_features.py
1.5 kB
| import pytest | |
| from fastapi.testclient import TestClient | |
| from backend.main import app | |
| from backend.calendar_generator import CalendarGenerator | |
| from datetime import datetime | |
| client = TestClient(app) | |
| def test_calendar_generator(): | |
| generator = CalendarGenerator() | |
| ics_content = generator.generate_ics("Test Med", "twice daily", "7 days") | |
| assert "BEGIN:VCALENDAR" in ics_content | |
| assert "SUMMARY:Take Test Med" in ics_content | |
| assert "END:VCALENDAR" in ics_content | |
| def test_interaction_endpoint_mock(): | |
| # Mocking the Gemini response would be ideal, but for now we test the endpoint structure | |
| # This test assumes the backend handles the request correctly even if Gemini is mocked or fails gracefully | |
| response = client.post("/check-interactions", json={"medicines": ["Aspirin", "Warfarin"]}) | |
| # Since we are using a real API key in the code, this might actually hit Gemini if network is allowed. | |
| # If network is restricted, it should handle the error gracefully. | |
| assert response.status_code in [200, 500] | |
| if response.status_code == 200: | |
| data = response.json() | |
| assert "interactions" in data | |
| def test_calendar_endpoint(): | |
| response = client.post("/generate-calendar", json={ | |
| "medicine_name": "Amoxicillin", | |
| "frequency": "TID", | |
| "duration": "5 days" | |
| }) | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "download_url" in data | |
| assert data["download_url"].startswith("/export/calendar/") | |