Skip to content

Commit

Permalink
Improve reconnect (#273)
Browse files Browse the repository at this point in the history
* Improve reconnect, wip

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* remove grid tariff logging

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* has realtime device

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* improve reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* black

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* improve reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* mypy

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* Improve reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* Improve reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* Improve reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* improve reconnect, wip

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* adjust mypy

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* reconnect refactor

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* tibber home

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* ws

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* reconnect

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

* black

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>

---------

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>
  • Loading branch information
Danielhiversen authored Jul 10, 2023
1 parent 35dcd18 commit 875e241
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 341 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/code_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ jobs:
isort --check-only **/*.py
- name: Pylint Code Linter
run: |
pylint $SRC_FOLDER
pylint --enable useless-suppression $SRC_FOLDER
- name: MyPy
run: |
mypy --disallow-incomplete-defs --no-implicit-optional $SRC_FOLDER
mypy --disallow-incomplete-defs --no-implicit-optional --strict --no-warn-return-any $SRC_FOLDER
- name: black
run: black --check $SRC_FOLDER
- name: pytest
run: |
pytest test/test.py
13 changes: 7 additions & 6 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.mark.asyncio
async def test_tibber_no_session():
tibber_connection = tibber.Tibber()
tibber_connection = tibber.Tibber(user_agent="test",)
await tibber_connection.update_info()

assert tibber_connection.name == "Arya Stark"
Expand All @@ -24,7 +24,7 @@ async def test_tibber_no_session():
@pytest.mark.asyncio
async def test_tibber():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(websession=session)
tibber_connection = tibber.Tibber(websession=session, user_agent="test",)
await tibber_connection.update_info()

assert tibber_connection.name == "Arya Stark"
Expand All @@ -47,7 +47,7 @@ async def test_tibber():
assert home.price_total == {}
assert home.current_price_info == {}

home.sync_update_current_price_info()
await home.update_current_price_info()
assert home.current_price_total > 0
assert isinstance(home.current_price_info.get("energy"), (float, int))
assert isinstance(home.current_price_info.get("startsAt"), str)
Expand All @@ -74,7 +74,7 @@ async def test_tibber():
async def test_tibber_invalid_token():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(
access_token="INVALID_TOKEN", websession=session
access_token="INVALID_TOKEN", websession=session, user_agent="test",
)
with pytest.raises(
InvalidLogin, match="Context creation failed: invalid token"
Expand All @@ -87,7 +87,7 @@ async def test_tibber_invalid_token():
@pytest.mark.asyncio
async def test_tibber_invalid_query():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(websession=session)
tibber_connection = tibber.Tibber(websession=session, user_agent="test",)

with pytest.raises(
FatalHttpException, match="Syntax Error*"
Expand All @@ -101,7 +101,7 @@ async def test_tibber_invalid_query():
@pytest.mark.asyncio
async def test_tibber_notification():
async with aiohttp.ClientSession() as session:
tibber_connection = tibber.Tibber(websession=session)
tibber_connection = tibber.Tibber(websession=session, user_agent="test",)
await tibber_connection.update_info()
assert not await tibber_connection.send_notification("Test tittle", "message")

Expand All @@ -112,6 +112,7 @@ async def test_tibber_token():
tibber_connection = tibber.Tibber(
access_token="d11a43897efa4cf478afd659d6c8b7117da9e33b38232fd454b0e9f28af98012",
websession=session,
user_agent="test",
)
await tibber_connection.update_info()

Expand Down
Loading

0 comments on commit 875e241

Please sign in to comment.