diff --git a/src/__pycache__/__init__.cpython-311.pyc b/src/__pycache__/__init__.cpython-311.pyc index 426c248..a55b27f 100644 Binary files a/src/__pycache__/__init__.cpython-311.pyc and b/src/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/__pycache__/config.cpython-311.pyc b/src/__pycache__/config.cpython-311.pyc index 95f6f55..33be3f6 100644 Binary files a/src/__pycache__/config.cpython-311.pyc and b/src/__pycache__/config.cpython-311.pyc differ diff --git a/src/__pycache__/enums.cpython-311.pyc b/src/__pycache__/enums.cpython-311.pyc index 1c7f55d..8d88bbf 100644 Binary files a/src/__pycache__/enums.cpython-311.pyc and b/src/__pycache__/enums.cpython-311.pyc differ diff --git a/src/__pycache__/models.cpython-311.pyc b/src/__pycache__/models.cpython-311.pyc index 8b5292e..0af1c15 100644 Binary files a/src/__pycache__/models.cpython-311.pyc and b/src/__pycache__/models.cpython-311.pyc differ diff --git a/src/auth/__pycache__/__init__.cpython-311.pyc b/src/auth/__pycache__/__init__.cpython-311.pyc index e42b5d5..224f452 100644 Binary files a/src/auth/__pycache__/__init__.cpython-311.pyc and b/src/auth/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/auth/__pycache__/model.cpython-311.pyc b/src/auth/__pycache__/model.cpython-311.pyc index 628300a..e8edab1 100644 Binary files a/src/auth/__pycache__/model.cpython-311.pyc and b/src/auth/__pycache__/model.cpython-311.pyc differ diff --git a/src/auth/__pycache__/service.cpython-311.pyc b/src/auth/__pycache__/service.cpython-311.pyc index daf1c83..d361941 100644 Binary files a/src/auth/__pycache__/service.cpython-311.pyc and b/src/auth/__pycache__/service.cpython-311.pyc differ diff --git a/src/database/__pycache__/__init__.cpython-311.pyc b/src/database/__pycache__/__init__.cpython-311.pyc index 72fb57c..4badd8c 100644 Binary files a/src/database/__pycache__/__init__.cpython-311.pyc and b/src/database/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/database/__pycache__/core.cpython-311.pyc b/src/database/__pycache__/core.cpython-311.pyc index 83c2bed..2463f5b 100644 Binary files a/src/database/__pycache__/core.cpython-311.pyc and b/src/database/__pycache__/core.cpython-311.pyc differ diff --git a/src/database/__pycache__/service.cpython-311.pyc b/src/database/__pycache__/service.cpython-311.pyc index 0166c2f..e62533c 100644 Binary files a/src/database/__pycache__/service.cpython-311.pyc and b/src/database/__pycache__/service.cpython-311.pyc differ diff --git a/src/masterdata/__pycache__/__init__.cpython-311.pyc b/src/masterdata/__pycache__/__init__.cpython-311.pyc index 3239661..7e1190c 100644 Binary files a/src/masterdata/__pycache__/__init__.cpython-311.pyc and b/src/masterdata/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/masterdata/__pycache__/model.cpython-311.pyc b/src/masterdata/__pycache__/model.cpython-311.pyc index 892b12a..ae67aeb 100644 Binary files a/src/masterdata/__pycache__/model.cpython-311.pyc and b/src/masterdata/__pycache__/model.cpython-311.pyc differ diff --git a/src/masterdata/__pycache__/schema.cpython-311.pyc b/src/masterdata/__pycache__/schema.cpython-311.pyc index f6c2f5a..7082e24 100644 Binary files a/src/masterdata/__pycache__/schema.cpython-311.pyc and b/src/masterdata/__pycache__/schema.cpython-311.pyc differ diff --git a/src/masterdata/__pycache__/service.cpython-311.pyc b/src/masterdata/__pycache__/service.cpython-311.pyc index 79d928c..0f5f22e 100644 Binary files a/src/masterdata/__pycache__/service.cpython-311.pyc and b/src/masterdata/__pycache__/service.cpython-311.pyc differ diff --git a/test_run.log b/test_run.log new file mode 100644 index 0000000..168ac3b --- /dev/null +++ b/test_run.log @@ -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 + from src.masterdata.service import calculate_pmt +src\masterdata\service.py:6: in + from src.database.service import search_filter_sort_paginate +src\database\service.py:7: in + from .core import DbSession +src\database\core.py:19: in + from src.config import SQLALCHEMY_DATABASE_URI, COLLECTOR_URI +src\config.py:99: in + 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 + from src.masterdata.service import create, get +src\masterdata\service.py:6: in + from src.database.service import search_filter_sort_paginate +src\database\service.py:7: in + from .core import DbSession +src\database\core.py:19: in + from src.config import SQLALCHEMY_DATABASE_URI, COLLECTOR_URI +src\config.py:99: in + 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 ============================== diff --git a/tests/conftest.py b/tests/conftest.py index 29f621b..3360e93 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,13 @@ -# import os +import os -# # Set dummy environment variables for testing -# os.environ["DATABASE_HOSTNAME"] = "localhost" -# os.environ["DATABASE_CREDENTIAL_USER"] = "test" -# os.environ["DATABASE_CREDENTIAL_PASSWORD"] = "test" -# os.environ["COLLECTOR_CREDENTIAL_USER"] = "test" -# os.environ["COLLECTOR_CREDENTIAL_PASSWORD"] = "test" -# os.environ["DEV_USERNAME"] = "test" -# os.environ["DEV_PASSWORD"] = "test" +# Set dummy environment variables for testing +os.environ["DATABASE_HOSTNAME"] = "localhost" +os.environ["DATABASE_CREDENTIAL_USER"] = "test" +os.environ["DATABASE_CREDENTIAL_PASSWORD"] = "test" +os.environ["COLLECTOR_CREDENTIAL_USER"] = "test" +os.environ["COLLECTOR_CREDENTIAL_PASSWORD"] = "test" +os.environ["DEV_USERNAME"] = "test" +os.environ["DEV_PASSWORD"] = "test" # import asyncio # from typing import AsyncGenerator, Generator diff --git a/tests/e2e/test_acquisition_cost.py b/tests/e2e/test_acquisition_cost.py deleted file mode 100644 index e748bbd..0000000 --- a/tests/e2e/test_acquisition_cost.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_equipment.py b/tests/e2e/test_equipment.py deleted file mode 100644 index 53eede2..0000000 --- a/tests/e2e/test_equipment.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_equipment_master.py b/tests/e2e/test_equipment_master.py deleted file mode 100644 index a75f10f..0000000 --- a/tests/e2e/test_equipment_master.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_healthcheck.py b/tests/e2e/test_healthcheck.py deleted file mode 100644 index 0908cd7..0000000 --- a/tests/e2e/test_healthcheck.py +++ /dev/null @@ -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"} diff --git a/tests/e2e/test_masterdata.py b/tests/e2e/test_masterdata.py deleted file mode 100644 index aa4c215..0000000 --- a/tests/e2e/test_masterdata.py +++ /dev/null @@ -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 diff --git a/tests/e2e/test_masterdata_simulations.py b/tests/e2e/test_masterdata_simulations.py deleted file mode 100644 index 3037264..0000000 --- a/tests/e2e/test_masterdata_simulations.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_plant_fs_transaction.py b/tests/e2e/test_plant_fs_transaction.py deleted file mode 100644 index dbdc94e..0000000 --- a/tests/e2e/test_plant_fs_transaction.py +++ /dev/null @@ -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 diff --git a/tests/e2e/test_plant_masterdata.py b/tests/e2e/test_plant_masterdata.py deleted file mode 100644 index ea5f9a4..0000000 --- a/tests/e2e/test_plant_masterdata.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_plant_transaction.py b/tests/e2e/test_plant_transaction.py deleted file mode 100644 index 5518e4a..0000000 --- a/tests/e2e/test_plant_transaction.py +++ /dev/null @@ -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 diff --git a/tests/e2e/test_simulation.py b/tests/e2e/test_simulation.py deleted file mode 100644 index e44ba9f..0000000 --- a/tests/e2e/test_simulation.py +++ /dev/null @@ -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" diff --git a/tests/e2e/test_yeardata.py b/tests/e2e/test_yeardata.py deleted file mode 100644 index b187bdd..0000000 --- a/tests/e2e/test_yeardata.py +++ /dev/null @@ -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"