chore: update tests to adaped to new structure
This commit is contained in:
parent
d87d0cce11
commit
ee8f54cf06
8 changed files with 128 additions and 0 deletions
20
tests/test_api.py
Normal file
20
tests/test_api.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from fastapi.testclient import TestClient
|
||||
from api.main import app
|
||||
import pytest
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
def test_get_status():
|
||||
response = client.get("/status")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "operational"
|
||||
|
||||
def test_get_current_price_no_data(mocker):
|
||||
# Mock database connection to return no data
|
||||
mock_db = mocker.patch("utils.database.get_connection")
|
||||
mock_con = mock_db.return_value.__enter__.return_value
|
||||
mock_con.execute.return_value.fetchone.return_value = None
|
||||
|
||||
response = client.get("/current-price")
|
||||
assert response.status_code == 404
|
||||
assert response.json()["detail"] == "No data available"
|
||||
Loading…
Add table
Add a link
Reference in a new issue