Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test collection #302

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install depencency
- name: Install dependency
run: |
pip install -r requirements.txt
pip install dlint black flake8 flake8-bugbear flake8-deprecated flake8-executable isort pylint pytest pytest-cov pytest-asyncio mypy ruff
Expand All @@ -46,4 +46,4 @@ jobs:
run: ruff check $SRC_FOLDER
- name: pytest
run: |
pytest test/test.py
pytest
1 change: 1 addition & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Provide tests."""
42 changes: 23 additions & 19 deletions test/test.py → test/test_tibber.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
"""
Tests for pyTibber
"""
import os
import sys
"""Tests for pyTibber."""

import pytest

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
import aiohttp # noqa: E402
import aiohttp

import tibber # noqa: E402
import tibber
from tibber.exceptions import FatalHttpExceptionError, InvalidLoginError


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

assert tibber_connection.name == "Arya Stark"
Expand All @@ -24,7 +21,10 @@ 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, user_agent="test",)
tibber_connection = tibber.Tibber(
websession=session,
user_agent="test",
)
await tibber_connection.update_info()

assert tibber_connection.name == "Arya Stark"
Expand Down Expand Up @@ -74,11 +74,11 @@ 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, user_agent="test",
access_token="INVALID_TOKEN",
websession=session,
user_agent="test",
)
with pytest.raises(
InvalidLoginError, match="Context creation failed: invalid token"
):
with pytest.raises(InvalidLoginError, match="Context creation failed: invalid token"):
await tibber_connection.update_info()
assert not tibber_connection.name
assert tibber_connection.get_homes() == []
Expand All @@ -87,11 +87,12 @@ 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, user_agent="test",)
tibber_connection = tibber.Tibber(
websession=session,
user_agent="test",
)

with pytest.raises(
FatalHttpExceptionError, match="Syntax Error*"
):
with pytest.raises(FatalHttpExceptionError, match="Syntax Error*"):
await tibber_connection.execute("invalidquery")

assert not tibber_connection.name
Expand All @@ -101,7 +102,10 @@ 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, user_agent="test",)
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 Down
Loading