File size: 1,903 Bytes
9d4bd7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest
import httpx
pytest_plugins = ["pytest_asyncio"]

# @pytest.mark.asyncio
# async def test_list_funds(client, initialize_tests):
#     async with httpx.AsyncClient() as async_client:
#         # Import funds first
#         await async_client.post("http://localhost:8001/utt/import-all")
        
#         response = await async_client.get("http://localhost:8001/utt/")
#         assert response.status_code == 200
#         data = response.json()
#         assert data["success"] == True
#         assert "data" in data
#         assert len(data["data"]) > 0

@pytest.mark.asyncio
async def test_get_fund_data(client, initialize_tests):
    async with httpx.AsyncClient() as async_client:
        # Import funds first
        # await async_client.post("http://localhost:8001/utt/import-all")
        
        # Get specific fund data
        response = await async_client.get("http://localhost:8001/utt/umoja")
        assert response.status_code == 200
        data = response.json()
        assert data["success"] == True
        assert data["data"]["fund"]["symbol"] == "umoja"
        assert "data" in data["data"]

@pytest.mark.asyncio
async def test_get_fund_data_not_found(client, initialize_tests):
    async with httpx.AsyncClient() as async_client:
        response = await async_client.get("http://localhost:8001/utt/INVALID")
        assert response.status_code == 404
        data = response.json()
        assert data["success"] == False
        assert "Fund not found" in data["message"]

# @pytest.mark.asyncio
# async def test_queue_import_utt(client, initialize_tests):
#     async with httpx.AsyncClient() as async_client:
#         response = await async_client.post("http://localhost:8001/utt/import-all")
#         assert response.status_code == 200
#         data = response.json()
#         assert data["success"] == True
#         assert "task_id" in data["data"]