Merge pull request #7 from Patrick762/dev
Removed type checks for API client
This commit is contained in:
2
setup.py
2
setup.py
@@ -9,7 +9,7 @@ here = os.path.abspath(os.path.dirname(__file__))
|
||||
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
|
||||
long_description = "\n" + fh.read()
|
||||
|
||||
VERSION = "0.0.10"
|
||||
VERSION = "0.0.11"
|
||||
DESCRIPTION = "Stream Deck API Library"
|
||||
|
||||
# Setting up
|
||||
|
||||
@@ -38,28 +38,6 @@ class StreamDeckApi:
|
||||
on_ws_connect (Callable[[], None] or None): Callback on websocket connected
|
||||
"""
|
||||
|
||||
# Type checks
|
||||
if on_button_press is not None and not isinstance(
|
||||
on_button_press, Callable[[str], None]
|
||||
):
|
||||
raise TypeError()
|
||||
if on_button_release is not None and not isinstance(
|
||||
on_button_release, Callable[[str], None]
|
||||
):
|
||||
raise TypeError()
|
||||
if on_status_update is not None and not isinstance(
|
||||
on_status_update, Callable[[SDInfo], None]
|
||||
):
|
||||
raise TypeError()
|
||||
if on_ws_message is not None and not isinstance(
|
||||
on_ws_message, Callable[[SDWebsocketMessage], None]
|
||||
):
|
||||
raise TypeError()
|
||||
if on_ws_connect is not None and not isinstance(
|
||||
on_ws_connect, Callable[[], None]
|
||||
):
|
||||
raise TypeError()
|
||||
|
||||
self._host = host
|
||||
self._on_button_press = on_button_press
|
||||
self._on_button_release = on_button_release
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""Unittests for API client."""
|
||||
|
||||
import unittest
|
||||
import streamdeckapi
|
||||
|
||||
|
||||
class TestApi(unittest.TestCase):
|
||||
"""Api Test Case."""
|
||||
|
||||
def test_constructor(self):
|
||||
"""Constructor test."""
|
||||
host = "host.local"
|
||||
|
||||
# Test valid types
|
||||
api = streamdeckapi.StreamDeckApi(host)
|
||||
self.assertEqual(api.host, host)
|
||||
|
||||
streamdeckapi.StreamDeckApi(host, on_button_press=None)
|
||||
streamdeckapi.StreamDeckApi(host, on_button_release=None)
|
||||
streamdeckapi.StreamDeckApi(host, on_status_update=None)
|
||||
streamdeckapi.StreamDeckApi(host, on_ws_connect=None)
|
||||
streamdeckapi.StreamDeckApi(host, on_ws_message=None)
|
||||
|
||||
# Test some invalid types
|
||||
for i_type in ["string", 2345, [321, 6457], {"key": "value"}]:
|
||||
with self.assertRaises(TypeError):
|
||||
_ = streamdeckapi.StreamDeckApi(host, on_button_press=i_type)
|
||||
with self.assertRaises(TypeError):
|
||||
_ = streamdeckapi.StreamDeckApi(host, on_button_release=i_type)
|
||||
with self.assertRaises(TypeError):
|
||||
_ = streamdeckapi.StreamDeckApi(host, on_status_update=i_type)
|
||||
with self.assertRaises(TypeError):
|
||||
_ = streamdeckapi.StreamDeckApi(host, on_ws_connect=i_type)
|
||||
with self.assertRaises(TypeError):
|
||||
_ = streamdeckapi.StreamDeckApi(host, on_ws_message=i_type)
|
||||
Reference in New Issue
Block a user