From 279eef8590f6d6df4c8ae027a1d491d4a3e19de0 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 9 Sep 2020 15:48:21 +0100 Subject: [PATCH] Removed unused Event class --- src/labthings/event.py | 65 --------------------------------------- src/labthings/labthing.py | 1 - src/labthings/td.py | 1 - tests/test_event.py | 29 ----------------- 4 files changed, 96 deletions(-) delete mode 100644 src/labthings/event.py delete mode 100644 tests/test_event.py diff --git a/src/labthings/event.py b/src/labthings/event.py deleted file mode 100644 index 4a2ba296..00000000 --- a/src/labthings/event.py +++ /dev/null @@ -1,65 +0,0 @@ -import datetime - - -class Event: - """ """ - - def __init__(self, name, schema=None): - self.name = name - self.schema = schema - - self.events = [] # TODO: Make rotating - - def emit(self, data): - """ - - :param data: - - """ - response = { - "messageType": "event", - "timestamp": datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"), - "data": {self.name: data}, - } # TODO: Format data with schema - self.events.append(response) - return response - - -class PropertyStatusEvent: - """ """ - - def __init__(self, property_name, schema=None): - self.name = property_name - - def emit(self, data): - """ - - :param data: - - """ - response = { - "messageType": "propertyStatus", - "timestamp": datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"), - "data": {self.name: data}, - } - return response - - -class ActionStatusEvent: - """ """ - - def __init__(self, action_name, schema=None): - self.name = action_name - - def emit(self, data): - """ - - :param data: - - """ - response = { - "messageType": "actionStatus", - "timestamp": datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"), - "data": {self.name: data}, - } - return response diff --git a/src/labthings/labthing.py b/src/labthings/labthing.py index 3293c8f4..4543967d 100644 --- a/src/labthings/labthing.py +++ b/src/labthings/labthing.py @@ -13,7 +13,6 @@ from .default_views.docs import SwaggerUIView, docs_blueprint from .default_views.extensions import ExtensionList from .default_views.root import RootView -from .event import Event from .extensions import BaseExtension from .httperrorhandler import SerializedExceptionHandler from .json.encoder import LabThingsJSONEncoder diff --git a/src/labthings/td.py b/src/labthings/td.py index 5809751d..42b7c6d8 100644 --- a/src/labthings/td.py +++ b/src/labthings/td.py @@ -1,6 +1,5 @@ from flask import has_request_context, request -from .event import Event from .find import current_labthing from .json.schemas import rule_to_params, rule_to_path, schema_to_json from .utilities import ResourceURL, get_docstring, snake_to_camel diff --git a/tests/test_event.py b/tests/test_event.py deleted file mode 100644 index 3368680e..00000000 --- a/tests/test_event.py +++ /dev/null @@ -1,29 +0,0 @@ -from labthings import event - - -def test_event(): - e = event.Event("eventName") - event_data = {"key": "value"} - - response = e.emit(event_data) - assert response.get("messageType") == "event" - assert response.get("data") == {"eventName": event_data} - assert response in e.events - - -def test_property_status_event(): - e = event.PropertyStatusEvent("propertyName") - event_data = {"key": "value"} - - response = e.emit(event_data) - assert response.get("messageType") == "propertyStatus" - assert response.get("data") == {"propertyName": event_data} - - -def test_action_status_event(): - e = event.ActionStatusEvent("actionName") - event_data = {"key": "value"} - - response = e.emit(event_data) - assert response.get("messageType") == "actionStatus" - assert response.get("data") == {"actionName": event_data}