Skip to content

Commit

Permalink
Update code with Ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
klaasnicolaas authored and renovate[bot] committed Mar 7, 2024
1 parent 85b88c7 commit 59a8d25
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/easyenergy/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for EasyEnergy API client."""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions src/easyenergy/easyenergy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous Python client for the easyEnergy API."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions src/easyenergy/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Data models for the easyEnergy API."""

from __future__ import annotations

from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Asynchronous Python client for the easyEnergy API."""

from pathlib import Path


Expand Down
40 changes: 25 additions & 15 deletions tests/test_easyenergy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Basic tests for the easyEnergy API."""

# pylint: disable=protected-access
import asyncio
from typing import Any
Expand Down Expand Up @@ -91,23 +92,29 @@ async def test_client_error() -> None:
"""Test request client error is handled correctly."""
async with ClientSession() as session:
client = EasyEnergy(session=session)
with patch.object(
session,
"request",
side_effect=ClientError,
), pytest.raises(EasyEnergyConnectionError):
with (
patch.object(
session,
"request",
side_effect=ClientError,
),
pytest.raises(EasyEnergyConnectionError),
):
assert await client._request("test")


async def test_dns_error() -> None:
"""Test request DNS error is handled correctly."""
async with ClientSession() as session:
client = EasyEnergy(session=session)
with patch.object(
DNSResolver,
"query",
side_effect=DNSError,
), pytest.raises(EasyEnergyConnectionError):
with (
patch.object(
DNSResolver,
"query",
side_effect=DNSError,
),
pytest.raises(EasyEnergyConnectionError),
):
assert await client._request("test")


Expand All @@ -117,9 +124,12 @@ async def test_empty_dns_error() -> None:
client = EasyEnergy(session=session)
dns_result: Any = asyncio.Future()
dns_result.set_result(None)
with patch.object(
DNSResolver,
"query",
return_value=dns_result,
), pytest.raises(EasyEnergyConnectionError):
with (
patch.object(
DNSResolver,
"query",
return_value=dns_result,
),
pytest.raises(EasyEnergyConnectionError),
):
assert await client._request("test")
1 change: 1 addition & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test the models."""

from datetime import UTC, date, datetime

import pytest
Expand Down

0 comments on commit 59a8d25

Please sign in to comment.