diff --git a/requirements_test.txt b/requirements_test.txt index 7111b70..8e6a7f9 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,5 @@ pytest==8.2.2 pytest-cov==5.0.0 -pytest-dataset==0.3.2 pytest-xdist==3.6.1 requests-mock[fixture]==1.12.1 syrupy==4.6.1 diff --git a/src/pyecotrend_ista/const.py b/src/pyecotrend_ista/const.py index 7715f94..9436182 100644 --- a/src/pyecotrend_ista/const.py +++ b/src/pyecotrend_ista/const.py @@ -1,6 +1,6 @@ """Constants for PyEcotrendIsta.""" -VERSION = "3.3.1" +VERSION = "3.3.2" API_BASE_URL = "https://api.prod.eed.ista.com/" diff --git a/tests/conftest.py b/tests/conftest.py index 1841e35..972138b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ """Fixtures for Tests.""" from http import HTTPStatus +from pathlib import Path import pytest from requests_mock.mocker import Mocker as RequestsMock @@ -12,6 +13,13 @@ DEMO_EMAIL = DEMO_USER_ACCOUNT TEST_PASSWORD = "password" +@pytest.fixture +def json_data(request) -> str: + """Load json test data.""" + file = getattr(request, "param", "test_data") + path = Path(__file__).parent / "data" / f"{file}.json" + return path.read_text(encoding="utf-8") + @pytest.fixture def ista_client(request) -> PyEcotrendIsta: diff --git a/tests/test_consumptions.py b/tests/test_consumptions.py index b0cd817..d271d1b 100644 --- a/tests/test_consumptions.py +++ b/tests/test_consumptions.py @@ -12,10 +12,10 @@ from pyecotrend_ista.const import API_BASE_URL -def test_get_comsumption_data(ista_client: PyEcotrendIsta, requests_mock: RequestsMock, snapshot: SnapshotAssertion, dataset) -> None: +def test_get_comsumption_data(ista_client: PyEcotrendIsta, requests_mock: RequestsMock, snapshot: SnapshotAssertion, json_data: str,) -> None: """Test `_set_account` method.""" - requests_mock.get(f"{API_BASE_URL}consumptions", json=dataset["test_data"]) + requests_mock.get(f"{API_BASE_URL}consumptions", text=json_data) assert ista_client.get_consumption_data("26e93f1a-c828-11ea-87d0-0242ac130003") == snapshot @@ -59,10 +59,10 @@ def test_get_comsumption_data_exceptions(requests_mock: RequestsMock, ista_clien ista_client.get_consumption_data("26e93f1a-c828-11ea-87d0-0242ac130003") -def test_consum_raw(ista_client: PyEcotrendIsta, requests_mock: RequestsMock, snapshot: SnapshotAssertion, dataset) -> None: +def test_consum_raw(ista_client: PyEcotrendIsta, requests_mock: RequestsMock, snapshot: SnapshotAssertion, json_data: str) -> None: """Test `cunsum_raw` method.""" - requests_mock.get(f"{API_BASE_URL}consumptions", json=dataset["test_data"]) + requests_mock.get(f"{API_BASE_URL}consumptions", text=json_data) result = ista_client.consum_raw(obj_uuid="26e93f1a-c828-11ea-87d0-0242ac130003") # consum_raw returns consum_types list in random order, so we exclude it from snapshot matcher @@ -112,14 +112,14 @@ def test_consum_raw_filters( ista_client: PyEcotrendIsta, requests_mock: RequestsMock, snapshot: SnapshotAssertion, - dataset, + json_data: str, select_year: list[int], select_month: list[int], filter_none: bool, ) -> None: """Test `cunsum_raw` method.""" - requests_mock.get(f"{API_BASE_URL}consumptions", json=dataset["test_data"]) + requests_mock.get(f"{API_BASE_URL}consumptions", text=json_data) result = ista_client.consum_raw( obj_uuid="26e93f1a-c828-11ea-87d0-0242ac130003", select_year=select_year,