Merge branch 'main' of 145.223.23.187:CIzz22/be-lcca
commit
760aa0229e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,51 @@
|
||||
C:\dev\be-lcca\venv\Lib\site-packages\pytest_asyncio\plugin.py:247: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
|
||||
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"
|
||||
|
||||
warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
|
||||
============================= test session starts =============================
|
||||
platform win32 -- Python 3.11.9, pytest-8.3.4, pluggy-1.5.0 -- C:\dev\be-lcca\venv\Scripts\python.exe
|
||||
cachedir: .pytest_cache
|
||||
rootdir: C:\dev\be-lcca
|
||||
configfile: pytest.ini
|
||||
plugins: anyio-4.8.0, Faker-30.10.0, asyncio-1.3.0
|
||||
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
|
||||
collecting ... collected 0 items / 2 errors
|
||||
|
||||
=================================== ERRORS ====================================
|
||||
____________ ERROR collecting tests/unit/test_masterdata_logic.py _____________
|
||||
tests\unit\test_masterdata_logic.py:2: in <module>
|
||||
from src.masterdata.service import calculate_pmt
|
||||
src\masterdata\service.py:6: in <module>
|
||||
from src.database.service import search_filter_sort_paginate
|
||||
src\database\service.py:7: in <module>
|
||||
from .core import DbSession
|
||||
src\database\core.py:19: in <module>
|
||||
from src.config import SQLALCHEMY_DATABASE_URI, COLLECTOR_URI
|
||||
src\config.py:99: in <module>
|
||||
DEV_USERNAME = config("DEV_USERNAME")
|
||||
venv\Lib\site-packages\starlette\config.py:90: in __call__
|
||||
return self.get(key, cast, default)
|
||||
venv\Lib\site-packages\starlette\config.py:107: in get
|
||||
raise KeyError(f"Config '{key}' is missing, and has no default.")
|
||||
E KeyError: "Config 'DEV_USERNAME' is missing, and has no default."
|
||||
___________ ERROR collecting tests/unit/test_masterdata_service.py ____________
|
||||
tests\unit\test_masterdata_service.py:3: in <module>
|
||||
from src.masterdata.service import create, get
|
||||
src\masterdata\service.py:6: in <module>
|
||||
from src.database.service import search_filter_sort_paginate
|
||||
src\database\service.py:7: in <module>
|
||||
from .core import DbSession
|
||||
src\database\core.py:19: in <module>
|
||||
from src.config import SQLALCHEMY_DATABASE_URI, COLLECTOR_URI
|
||||
src\config.py:99: in <module>
|
||||
DEV_USERNAME = config("DEV_USERNAME")
|
||||
venv\Lib\site-packages\starlette\config.py:90: in __call__
|
||||
return self.get(key, cast, default)
|
||||
venv\Lib\site-packages\starlette\config.py:107: in get
|
||||
raise KeyError(f"Config '{key}' is missing, and has no default.")
|
||||
E KeyError: "Config 'DEV_USERNAME' is missing, and has no default."
|
||||
=========================== short test summary info ===========================
|
||||
ERROR tests/unit/test_masterdata_logic.py - KeyError: "Config 'DEV_USERNAME' ...
|
||||
ERROR tests/unit/test_masterdata_service.py - KeyError: "Config 'DEV_USERNAME...
|
||||
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!
|
||||
============================== 2 errors in 0.67s ==============================
|
||||
@ -1,23 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_acquisition_costs(client: AsyncClient):
|
||||
response = await client.get("/acquisition-data")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_acquisition_cost(client: AsyncClient):
|
||||
payload = {
|
||||
"assetnum": "TEST-ASSET",
|
||||
"acquisition_cost": 1000.0,
|
||||
"acquisition_year": 2024,
|
||||
"residual_value": 100.0,
|
||||
"useful_life": 10
|
||||
}
|
||||
response = await client.post("/acquisition-data", json=payload)
|
||||
# Note: This might fail if the schema requires more fields OR if those are valid but I'm missing some required ones.
|
||||
# I'll check the schema if it fails, but for now I'll assume standard POST behavior.
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data created successfully"
|
||||
@ -1,26 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_equipments(client: AsyncClient):
|
||||
response = await client.get("/equipment")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_top_10_replacement_priorities(client: AsyncClient):
|
||||
response = await client.get("/equipment/top-10-replacement-priorities")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Top 10 Replacement Priorities Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_top_10_economic_life(client: AsyncClient):
|
||||
response = await client.get("/equipment/top-10-economic-life")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Top 10 Economic Life Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_count_remaining_life(client: AsyncClient):
|
||||
response = await client.get("/equipment/count-remaining-life")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Count remaining life retrieved successfully"
|
||||
@ -1,8 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_equipment_masters(client: AsyncClient):
|
||||
response = await client.get("/equipment-master")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
@ -1,8 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_healthcheck(client: AsyncClient):
|
||||
response = await client.get("/healthcheck")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "ok"}
|
||||
@ -1,97 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
import uuid
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_masterdata(client: AsyncClient):
|
||||
payload = {
|
||||
"name": "Test Master Data",
|
||||
"description": "Test Description",
|
||||
"unit_of_measurement": "unit",
|
||||
"value_num": 100.0,
|
||||
"value_str": "100",
|
||||
"seq": 1
|
||||
}
|
||||
response = await client.post("/masterdata", json=payload)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["message"] == "Data created successfully"
|
||||
assert data["data"]["name"] == "Test Master Data"
|
||||
assert "id" in data["data"]
|
||||
return data["data"]["id"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_masterdatas(client: AsyncClient):
|
||||
# First create one
|
||||
await client.post("/masterdata", json={
|
||||
"name": "Data 1",
|
||||
"description": "Desc 1",
|
||||
"unit_of_measurement": "u",
|
||||
"value_num": 1.0,
|
||||
"seq": 1
|
||||
})
|
||||
|
||||
response = await client.get("/masterdata")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["message"] == "Data retrieved successfully"
|
||||
assert len(data["data"]["items"]) >= 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_masterdata_by_id(client: AsyncClient):
|
||||
# Create one
|
||||
create_resp = await client.post("/masterdata", json={
|
||||
"name": "Data By ID",
|
||||
"description": "Desc",
|
||||
"unit_of_measurement": "u",
|
||||
"value_num": 2.0,
|
||||
"seq": 2
|
||||
})
|
||||
masterdata_id = create_resp.json()["data"]["id"]
|
||||
|
||||
response = await client.get(f"/masterdata/{masterdata_id}")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["data"]["name"] == "Data By ID"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_masterdata(client: AsyncClient):
|
||||
# Create one
|
||||
create_resp = await client.post("/masterdata", json={
|
||||
"name": "Old Name",
|
||||
"description": "Desc",
|
||||
"unit_of_measurement": "u",
|
||||
"value_num": 3.0,
|
||||
"seq": 3
|
||||
})
|
||||
masterdata_id = create_resp.json()["data"]["id"]
|
||||
|
||||
# Update it
|
||||
update_payload = {
|
||||
"name": "New Name",
|
||||
"value_num": 4.0
|
||||
}
|
||||
response = await client.post(f"/masterdata/update/{masterdata_id}", json=update_payload)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["data"]["name"] == "New Name"
|
||||
assert response.json()["data"]["value_num"] == 4.0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_delete_masterdata(client: AsyncClient):
|
||||
# Create one
|
||||
create_resp = await client.post("/masterdata", json={
|
||||
"name": "To Be Deleted",
|
||||
"description": "Desc",
|
||||
"unit_of_measurement": "u",
|
||||
"value_num": 5.0,
|
||||
"seq": 5
|
||||
})
|
||||
masterdata_id = create_resp.json()["data"]["id"]
|
||||
|
||||
# Delete it
|
||||
response = await client.post(f"/masterdata/delete/{masterdata_id}")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data deleted successfully"
|
||||
|
||||
# Verify it's gone
|
||||
get_resp = await client.get(f"/masterdata/{masterdata_id}")
|
||||
assert get_resp.status_code == 404
|
||||
@ -1,8 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_masterdata_simulations(client: AsyncClient):
|
||||
response = await client.get("/masterdata-simulations")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
@ -1,16 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_fs_transactions(client: AsyncClient):
|
||||
response = await client.get("/plant-fs-transaction-data")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_fs_charts(client: AsyncClient):
|
||||
response = await client.get("/plant-fs-transaction-data/charts")
|
||||
if response.status_code == 200:
|
||||
assert "items" in response.json()["data"]
|
||||
else:
|
||||
assert response.status_code == 404
|
||||
@ -1,20 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_plant_masterdatas(client: AsyncClient):
|
||||
response = await client.get("/plant-masterdata")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_plant_masterdata(client: AsyncClient):
|
||||
payload = {
|
||||
"name": "Plant Parameter",
|
||||
"description": "Plant Desc",
|
||||
"unit_of_measurement": "unit",
|
||||
"value_num": 10.5
|
||||
}
|
||||
response = await client.post("/plant-masterdata", json=payload)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data created successfully"
|
||||
@ -1,18 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_plant_transactions(client: AsyncClient):
|
||||
response = await client.get("/plant-transaction-data")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_plant_charts(client: AsyncClient):
|
||||
# This might return 404 if no data exists, but with my setup_db it should be empty
|
||||
response = await client.get("/plant-transaction-data/charts")
|
||||
# Actually, the service might raise 404 if it's empty
|
||||
if response.status_code == 200:
|
||||
assert "items" in response.json()["data"]
|
||||
else:
|
||||
assert response.status_code == 404
|
||||
@ -1,19 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_simulations(client: AsyncClient):
|
||||
response = await client.get("/simulations")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_simulation(client: AsyncClient):
|
||||
payload = {
|
||||
"label": "Test Simulation",
|
||||
"description": "Test Desc",
|
||||
"version": 1
|
||||
}
|
||||
response = await client.post("/simulations", json=payload)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["data"]["label"] == "Test Simulation"
|
||||
@ -1,18 +0,0 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_yeardatas(client: AsyncClient):
|
||||
response = await client.get("/yeardata")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data retrieved successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_yeardata(client: AsyncClient):
|
||||
payload = {
|
||||
"year": 2024,
|
||||
"description": "Test Year Data"
|
||||
}
|
||||
response = await client.post("/yeardata", json=payload)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["message"] == "Data created successfully"
|
||||
Loading…
Reference in New Issue