Skip to content

Commit

Permalink
Fix missing import; rename Connection folder
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-th committed Dec 15, 2024
1 parent cc01d7c commit 647bec4
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/homematicip/async_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from homematicip.base.channel_event import ChannelEvent
from homematicip.class_maps import *
from homematicip.client import Client
from homematicip.connection_v2.client_characteristics_builder import ClientCharacteristicsBuilder
from homematicip.connection_v2.connection_context import ConnectionContext, ConnectionContextBuilder
from homematicip.connection_v2.connection_factory import ConnectionFactory
from homematicip.connection_v2.websocket_handler import WebSocketHandler
from homematicip.connection.client_characteristics_builder import ClientCharacteristicsBuilder
from homematicip.connection.connection_context import ConnectionContext, ConnectionContextBuilder
from homematicip.connection.connection_factory import ConnectionFactory
from homematicip.connection.websocket_handler import WebSocketHandler
from homematicip.device import *
from homematicip.group import *
from homematicip.location import Location
Expand Down
4 changes: 2 additions & 2 deletions src/homematicip/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import uuid
from dataclasses import dataclass

from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection_v2.rest_connection import RestResult, RestConnection
from homematicip.connection.connection_context import ConnectionContext
from homematicip.connection.rest_connection import RestResult, RestConnection

LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src/homematicip/base/base_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class HmipThrottlingError(HmipConnectionError):

#
# class BaseConnection:
# """Base connection_v2 class.
# """Base connection class.
#
# Threaded and Async connection_v2 class must inherit from this."""
# Threaded and Async connection class must inherit from this."""
#
# _auth_token = ""
# _clientauth_token = ""
Expand Down
2 changes: 1 addition & 1 deletion src/homematicip/base/homematicip_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime

from homematicip.base.enums import AutoNameEnum
from homematicip.connection_v2.rest_connection import RestConnection, RestResult
from homematicip.connection.rest_connection import RestConnection, RestResult

LOGGER = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src/homematicip/cli/hmip_generate_auth_token.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
import asyncio
import configparser
import json
import time
from builtins import input

import homematicip
import homematicip.auth
from homematicip.connection_v2.connection_context import ConnectionContextBuilder
from homematicip.connection_v2.rest_connection import RestConnection
from homematicip.home import Home
from homematicip.connection.connection_context import ConnectionContextBuilder
from homematicip.connection.rest_connection import RestConnection


async def run_auth(access_point: str = None, devicename: str = None, pin: str = None):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dataclasses import dataclass

from homematicip.connection_v2.client_characteristics_builder import ClientCharacteristicsBuilder
from homematicip.connection_v2.client_token_builder import ClientTokenBuilder
from homematicip.connection_v2.connection_url_resolver import ConnectionUrlResolver
from homematicip.connection.client_characteristics_builder import ClientCharacteristicsBuilder
from homematicip.connection.client_token_builder import ClientTokenBuilder
from homematicip.connection.connection_url_resolver import ConnectionUrlResolver


class ConnectionContextBuilder:
Expand All @@ -14,10 +14,10 @@ def build_context(cls, accesspoint_id: str,
enforce_ssl: bool = True,
ssl_ctx=None):
"""
Create a new connection_v2 context and lookup urls
Create a new connection context and lookup urls
:param accesspoint_id: Access point id
:param lookup_url: Url to lookup the connection_v2 urls
:param lookup_url: Url to lookup the connection urls
:param auth_token: The Auth Token if exists. If no one is provided None will be used
:param enforce_ssl: Disable ssl verification by setting enforce_ssl to False
:param ssl_ctx: ssl context to use
Expand Down Expand Up @@ -57,10 +57,10 @@ def create(cls, access_point_id: str,
enforce_ssl: bool = True,
ssl_ctx=None):
"""
Create a new connection_v2 context.
Create a new connection context.
:param access_point_id: Access point id
:param lookup_url: Url to lookup the connection_v2 urls
:param lookup_url: Url to lookup the connection urls
:param auth_token: The Auth Token if exists. If no one is provided None will be used
:param enforce_ssl: Disable ssl verification by setting enforce_ssl to False
:param ssl_ctx: ssl context to use
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection_v2.rate_limited_rest_connection import RateLimitedRestConnection
from homematicip.connection_v2.rest_connection import RestConnection
from homematicip.connection.connection_context import ConnectionContext
from homematicip.connection.rate_limited_rest_connection import RateLimitedRestConnection
from homematicip.connection.rest_connection import RestConnection


class ConnectionFactory:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import json

from homematicip.connection_v2 import RATE_LIMITER_FILL_RATE, RATE_LIMITER_TOKENS
from homematicip.connection_v2.buckets import Buckets
from homematicip.connection_v2.rest_connection import RestConnection, RestResult
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection import RATE_LIMITER_FILL_RATE, RATE_LIMITER_TOKENS
from homematicip.connection.buckets import Buckets
from homematicip.connection.rest_connection import RestConnection, RestResult
from homematicip.connection.connection_context import ConnectionContext


class RateLimitedRestConnection(RestConnection):
Expand All @@ -14,7 +14,7 @@ def __init__(self,
fill_rate: int = RATE_LIMITER_FILL_RATE):
"""Initialize the RateLimitedRestConnection with a token bucket algorithm.
:param context: The connection_v2 context.
:param context: The connection context.
:param tokens: The number of tokens in the bucket. Default is 10.
:param fill_rate: The fill rate of the bucket in tokens per second. Default is 8."""
super().__init__(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import httpx

from homematicip.connection_v2 import ATTR_AUTH_TOKEN, ATTR_CLIENT_AUTH, THROTTLE_STATUS_CODE, ATTR_ACCESSPOINT_ID
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection import ATTR_AUTH_TOKEN, ATTR_CLIENT_AUTH, THROTTLE_STATUS_CODE, ATTR_ACCESSPOINT_ID
from homematicip.connection.connection_context import ConnectionContext
from homematicip.exceptions.connection_exceptions import HmipThrottlingError

LOGGER = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from websockets import connect
from websockets.exceptions import ConnectionClosed

from homematicip.connection_v2 import ATTR_AUTH_TOKEN, ATTR_CLIENT_AUTH
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection import ATTR_AUTH_TOKEN, ATTR_CLIENT_AUTH
from homematicip.connection.connection_context import ConnectionContext
from homematicip.exceptions.connection_exceptions import HmipServerCloseError

LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime, timedelta, timezone
from threading import Thread

from homematicip.connection_v2.connection_context import ConnectionContext, ConnectionContextBuilder
from homematicip.connection.connection_context import ConnectionContext, ConnectionContextBuilder

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

Expand Down
12 changes: 6 additions & 6 deletions tests/fake_hmip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from aiohttp.resolver import DefaultResolver
from aiohttp.test_utils import unused_port

from homematicip.connection_v2 import ATTR_CLIENT_AUTH, ATTR_AUTH_TOKEN
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection_v2.rest_connection import RestConnection
from homematicip.connection_v2.websocket_handler import WebSocketHandler
from homematicip.connection import ATTR_CLIENT_AUTH, ATTR_AUTH_TOKEN
from homematicip.connection.connection_context import ConnectionContext
from homematicip.connection.rest_connection import RestConnection
from homematicip.connection.websocket_handler import WebSocketHandler


class FakeResolver:
Expand Down Expand Up @@ -117,7 +117,7 @@ async def get_host(self, request):


class FakeConnectionHmip(BaseFakeHmip):
"""Test various connection_v2 issues"""
"""Test various connection issues"""

js_response = {"response": True}

Expand Down Expand Up @@ -164,7 +164,7 @@ async def websocket_handler(self, request):
await ws.prepare(request)
ws.send_bytes(b"abc")
await asyncio.sleep(2)
print("websocket connection_v2 closed")
print("websocket connection closed")

return ws

Expand Down
4 changes: 2 additions & 2 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest

from homematicip.auth import Auth
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection_v2.rest_connection import RestConnection
from homematicip.connection.connection_context import ConnectionContext
from homematicip.connection.rest_connection import RestConnection


@pytest.mark.asyncio
Expand Down
1 change: 1 addition & 0 deletions tests/test_functional_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import MagicMock, Mock
import pytest
from conftest import utc_offset
from homematicip.base.channel_event import ChannelEvent
from homematicip.base.enums import *
from homematicip.base.functionalChannels import *
from homematicip.device import *
Expand Down
4 changes: 2 additions & 2 deletions tests/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from conftest import utc_offset
from homematicip.base.channel_event import ChannelEvent
from homematicip.connection_v2.connection_context import ConnectionContext
from homematicip.connection.connection_context import ConnectionContext
from homematicip.device import Device, BaseDevice
from homematicip.functionalHomes import *
from homematicip.group import Group
Expand All @@ -20,7 +20,7 @@

def test_init():
context = ConnectionContext(auth_token="auth_token", accesspoint_id="access_point_id")
with patch('homematicip.connection_v2.connection_context.ConnectionContextBuilder.build_context',
with patch('homematicip.connection.connection_context.ConnectionContextBuilder.build_context',
return_value=context) as mock_create:
home = Home()
home.init('access_point_id', 'auth_token')
Expand Down

0 comments on commit 647bec4

Please sign in to comment.