-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Mulliken
committed
May 18, 2021
1 parent
6a5be46
commit 2e6c48f
Showing
5 changed files
with
128 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[metadata] | ||
# replace with your username: | ||
name = wyzeapy | ||
version = 0.0.23-beta.8 | ||
version = 0.0.23-beta.9 | ||
author = Mulliken LLC | ||
author_email = [email protected] | ||
description = Python client for private Wyze API | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2021. Mulliken, LLC - All Rights Reserved | ||
# You may use, distribute and modify this code under the terms | ||
# of the attached license. You should have received a copy of | ||
# the license with this file. If not, please write to: | ||
# [email protected] to receive a copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Copyright (c) 2021. Mulliken, LLC - All Rights Reserved | ||
# You may use, distribute and modify this code under the terms | ||
# of the attached license. You should have received a copy of | ||
# the license with this file. If not, please write to: | ||
# [email protected] to receive a copy | ||
|
||
import os | ||
import unittest | ||
from unittest import mock | ||
from typing import List | ||
|
||
from src.wyzeapy.client import Client | ||
from src.wyzeapy.types import Device, ThermostatProps | ||
|
||
|
||
class TestLogin(unittest.TestCase): | ||
def test_can_login(self): | ||
client = Client(os.getenv("WYZE_EMAIL"), os.getenv("WYZE_PASSWORD")) | ||
|
||
self.assertTrue(client.valid_login) | ||
|
||
def test_bad_login(self): | ||
client = Client("[email protected]", "BadPassword123") | ||
|
||
self.assertFalse(client.valid_login) | ||
|
||
|
||
class TestFunctions(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls._client = Client(os.getenv("WYZE_EMAIL"), os.getenv("WYZE_PASSWORD")) | ||
|
||
def test_get_devices_return_type(self): | ||
devices = self._client.get_devices() | ||
self.assertIsInstance(devices, List) | ||
for device in devices: | ||
self.assertIsInstance(device, Device) | ||
|
||
def test_turn_on_color_bulb(self): | ||
test_bulb = Device({ | ||
'mac': '7C78B214CF40', | ||
'product_type': 'MeshLight', | ||
'product_model': 'WLPA19C' | ||
}) | ||
|
||
self._client.turn_on(test_bulb) | ||
|
||
def test_turn_off_color_bulb(self): | ||
test_bulb = Device({ | ||
'mac': '7C78B214CF40', | ||
'product_type': 'MeshLight', | ||
'product_model': 'WLPA19C' | ||
}) | ||
|
||
self._client.turn_off(test_bulb) | ||
|
||
def test_turn_on_bulb(self): | ||
test_bulb = Device({ | ||
'mac': '2CAA8E325C52', | ||
'product_type': 'Light', | ||
'product_model': 'WLPA19' | ||
}) | ||
|
||
self._client.turn_on(test_bulb) | ||
|
||
def test_turn_off_bulb(self): | ||
test_bulb = Device({ | ||
'mac': '2CAA8E325C52', | ||
'product_type': 'Light', | ||
'product_model': 'WLPA19' | ||
}) | ||
|
||
self._client.turn_off(test_bulb) | ||
|
||
def test_unlock_door(self): | ||
test_lock = Device({ | ||
'mac': 'YD.LO1.46c36fcce6c550e527ff79bd8cef59c2', | ||
'product_type': 'Lock', | ||
'product_model': 'WLCK1' | ||
}) | ||
|
||
self._client.turn_off(test_lock) | ||
|
||
def test_lock_door(self): | ||
test_lock = Device({ | ||
'mac': 'YD.LO1.46c36fcce6c550e527ff79bd8cef59c2', | ||
'product_type': 'Lock', | ||
'product_model': 'WLCK1' | ||
}) | ||
|
||
self._client.turn_on(test_lock) | ||
|
||
def test_can_read_thermostat(self): | ||
test_thermostat = Device({ | ||
'mac': 'CO_EA1_31304635143637394a414e75', | ||
'product_type': 'Thermostat', | ||
'product_model': 'CO_EA1' | ||
}) | ||
|
||
info = self._client.get_thermostat_info(test_thermostat) | ||
|
||
self.assertIsInstance(info, List) | ||
for item in info: | ||
self.assertIsInstance(info, ThermostatProps) |