Skip to content

Commit

Permalink
(fix): fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakise committed Nov 23, 2021
1 parent 7a9eb3a commit bdb80c9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
2 changes: 0 additions & 2 deletions libdyson/cloud/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class DysonAccount:
"""Dyson account."""

_HOST = DYSON_API_HOST
_CERT = DYSON_CERT

def __init__(
self,
Expand Down Expand Up @@ -180,7 +179,6 @@ class DysonAccountCN(DysonAccount):
"""Dyson account in Mainland China."""

_HOST = DYSON_API_HOST_CN
_CERT = DYSON_CERT_CN

def login_mobile_otp(self, mobile: str) -> Callable[[str], dict]:
"""Login using phone number and OTP code."""
Expand Down
6 changes: 2 additions & 4 deletions tests/cloud/mocked_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import requests

from libdyson.cloud.account import DYSON_API_HEADERS, DYSON_API_HOST, DYSON_CERT
from libdyson.cloud.account import DYSON_API_HEADERS, DYSON_API_HOST


class MockedRequests:
Expand All @@ -14,7 +14,6 @@ class MockedRequests:
def __init__(self):
"""Initialize the mock."""
self.host = DYSON_API_HOST
self.cert = DYSON_CERT
self._handlers = {}

@property
Expand All @@ -27,11 +26,10 @@ def register_handler(self, method: str, path: str, handler: Callable) -> None:
self._handlers[(method, path)] = handler

def request(
self, method: str, url: str, headers=None, verify=None, **kwargs
self, method: str, url: str, headers=None, verify=True, **kwargs
) -> requests.Response:
"""Run mocked request function."""
assert headers == DYSON_API_HEADERS
assert verify == self.cert
assert url.startswith(self.host)
path = url[len(self.host) :]
response = requests.Response()
Expand Down
4 changes: 0 additions & 4 deletions tests/cloud/test_dyson_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
API_PATH_MOBILE_VERIFY,
API_PATH_USER_STATUS,
DYSON_API_HOST_CN,
DYSON_CERT_CN,
DysonAccountCN,
HTTPBearerAuth,
)
Expand Down Expand Up @@ -270,7 +269,6 @@ def _handle_email_request(
def test_login_mobile(mocked_requests: MockedRequests):
"""Test logging into account using phone number and otp code."""
mocked_requests.host = DYSON_API_HOST_CN
mocked_requests.cert = DYSON_CERT_CN

account = DysonAccountCN()
verify = account.login_mobile_otp(MOBILE)
Expand All @@ -296,7 +294,6 @@ def _handle_mobile_request(
return (429, None)

mocked_requests.host = DYSON_API_HOST_CN
mocked_requests.cert = DYSON_CERT_CN
mocked_requests.register_handler(
"POST", API_PATH_MOBILE_REQUEST, _handle_mobile_request
)
Expand All @@ -309,7 +306,6 @@ def _handle_mobile_request(
def test_account_auth_info_bearer(mocked_requests: MockedRequests):
"""Test initialize account with bearer auth info."""
mocked_requests.host = DYSON_API_HOST_CN
mocked_requests.cert = DYSON_CERT_CN
account = DysonAccountCN(AUTH_INFO_BEARER)
devices = account.devices()
assert len(devices) == 2
Expand Down

0 comments on commit bdb80c9

Please sign in to comment.