diff --git a/noxfile.py b/noxfile.py index 04a2bbb..2651e1b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,7 +9,7 @@ package = "flipr_api" -python_versions = ["3.9", "3.8", "3.7", "3.6"] +python_versions = ["3.10", "3.9", "3.8", "3.7", "3.6"] nox.options.sessions = ( "pre-commit", "safety", @@ -21,7 +21,7 @@ ) -@session(name="pre-commit", python="3.9") +@session(name="pre-commit", python="3.10") def precommit(session: Session) -> None: """Lint using pre-commit.""" args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"] @@ -41,7 +41,7 @@ def precommit(session: Session) -> None: session.run("pre-commit", *args) -@session(python="3.9") +@session(python="3.10") def safety(session: Session) -> None: """Scan dependencies for insecure packages.""" requirements = session.poetry.export_requirements() @@ -79,7 +79,7 @@ def coverage(session: Session) -> None: # Do not use session.posargs unless this is the only session. has_args = session.posargs and len(session._runner.manifest) == 1 # replace report by xml to generate an xml report for codecov.io - args = session.posargs if has_args else ["report"] + args = session.posargs if has_args else ["xml"] session.install("coverage[toml]") @@ -106,7 +106,7 @@ def xdoctest(session: Session) -> None: session.run("python", "-m", "xdoctest", package, *args) -@session(name="docs-build", python="3.9") +@session(name="docs-build", python="3.10") def docs_build(session: Session) -> None: """Build the documentation.""" args = session.posargs or ["docs", "docs/_build"] diff --git a/src/flipr_api/client.py b/src/flipr_api/client.py index 4e9cbb2..6fe0b53 100644 --- a/src/flipr_api/client.py +++ b/src/flipr_api/client.py @@ -119,6 +119,7 @@ def get_pool_measure_latest(self, flipr_id: str) -> Dict[str, Any]: "date_time": parse(json_resp["DateTime"]), "ph_status": json_resp["PH"]["DeviationSector"], "chlorine_status": json_resp["Desinfectant"]["DeviationSector"], + "battery": float(json_resp["Battery"]["Deviation"]), } def get_hub_state(self, hub_id: str) -> Dict[str, Any]: diff --git a/tests/test_client.py b/tests/test_client.py index 626c232..0e9d405 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -187,14 +187,16 @@ def test_integration_simple(requests_mock) -> None: # type: ignore red_ox = data["red_ox"] chlorine = data["chlorine"] ph = data["ph"] + battery = data["battery"] print( - "Valeurs de la piscine : le {:s} temperature = {:.2f}, redox = {:.2f}, chlorine = {:.5f}, ph = {:.2f}".format( + "Valeurs de la piscine : le {:s} temperature = {:.2f}, redox = {:.2f}, chlorine = {:.5f}, ph = {:.2f}, battery= {:.2f}".format( date_time.strftime("%Y-%m-%d %H:%M:%S"), temperature, red_ox, chlorine, ph, + battery, ) ) @@ -203,6 +205,7 @@ def test_integration_simple(requests_mock) -> None: # type: ignore assert chlorine == 0.31986785186370315 assert ph == 7.01 assert date_time.strftime("%Y-%m-%d %H:%M:%S") == "2021-02-01 07:40:21" + assert battery == 0.75 # Test hub id search list_hub = client.search_hub_ids() diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 39708c2..d89d289 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -24,7 +24,7 @@ def test_integration_simple() -> None: data = client.get_pool_measure_latest(FLIPR_ID) print( - "Valeurs de la piscine : le {:s} temperature = {:.2f}, redox = {:.2f}, chlorine = {:.5f}, ph = {:.2f}, Alerte PH = {:s}, Alerte chlore = {:s}".format( + "Valeurs de la piscine : le {:s} temperature = {:.2f}, redox = {:.2f}, chlorine = {:.5f}, ph = {:.2f}, Alerte PH = {:s}, Alerte chlore = {:s}, Battery ={:.2f}".format( data["date_time"].strftime("%Y-%m-%d %H:%M:%S"), data["temperature"], data["red_ox"], @@ -32,6 +32,7 @@ def test_integration_simple() -> None: data["ph"], data["ph_status"], data["chlorine_status"], + data["battery"], ) ) @@ -40,6 +41,7 @@ def test_integration_simple() -> None: assert data["chlorine"] > 0 assert data["ph"] > 0 assert data["date_time"] is not None + assert data["battery"] > 0 @pytest.mark.skip("Not an automated test but an example of usage with real values.")