Skip to content

Commit

Permalink
fix: moved device_key to start_update
Browse files Browse the repository at this point in the history
made more sense than init
  • Loading branch information
Lash-L committed Jan 18, 2023
1 parent df8d522 commit 1dddd7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/anova_wifi/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import Any

import requests
from sensor_state_data import SensorData, SensorDeviceClass, Units
Expand Down Expand Up @@ -32,14 +31,13 @@ class AnovaPrecisionCookerBinarySensor(StrEnum):


class AnovaPrecisionCooker(SensorData):
def __init__(self, device_key: str):
def __init__(self) -> None:
super().__init__()
self.device_key = device_key

def _start_update(self, data: Any) -> None:
def _start_update(self, device_key: str) -> None:
anova_status = (
requests.get(
f"https://anovaculinary.io/devices/{self.device_key}/states/?limit=1"
f"https://anovaculinary.io/devices/{device_key}/states/?limit=1"
)
.json()[0]
.get("body")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@


def test_can_create():
AnovaPrecisionCooker("")
AnovaPrecisionCooker()


@mock.patch("anova_wifi.parser.requests.get")
def test_data_1(requests_mocked):
apc = AnovaPrecisionCooker("")
apc = AnovaPrecisionCooker()
requests_mocked.return_value = MockResponse(json_data=dataset_one, status_code=200)
result = apc.update("")
print(result)
Expand Down

0 comments on commit 1dddd7f

Please sign in to comment.