Skip to content

Commit

Permalink
Add extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas committed Dec 17, 2021
1 parent 2270875 commit 719aa7a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ paths = ["omnikinverter"]
verbose = true

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["setuptools","poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
36 changes: 36 additions & 0 deletions tests/test_omnik.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,42 @@
from . import load_fixtures


@pytest.mark.asyncio
async def test_json_request(aresponses):
"""Test JSON response is handled correctly."""
aresponses.add(
"example.com",
"/test",
"GET",
aresponses.Response(
status=200,
headers={"Content-Type": "application/json"},
text='{"status": "ok"}',
),
)
async with aiohttp.ClientSession() as session:
omnik_inverter = OmnikInverter("example.com", session=session)
await omnik_inverter.request("test")
await omnik_inverter.close()


@pytest.mark.asyncio
async def test_internal_session(aresponses):
"""Test JSON response is handled correctly."""
aresponses.add(
"example.com",
"/test",
"GET",
aresponses.Response(
status=200,
headers={"Content-Type": "application/json"},
text='{"status": "ok"}',
),
)
async with OmnikInverter("example.com") as omnik_inverter:
await omnik_inverter.request("test")


@pytest.mark.asyncio
async def test_wrong_js_source(aresponses):
"""Test on wrong data source error raise."""
Expand Down

0 comments on commit 719aa7a

Please sign in to comment.