From 59730b4cec1c30818679e8a074258effe3e80bfd Mon Sep 17 00:00:00 2001 From: Josef Date: Thu, 12 Dec 2019 14:55:37 +0800 Subject: [PATCH] fix --- notiframe/Notiframe 2.py | 88 ---------------------------------------- notiframe/Notiframe.py | 3 ++ 2 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 notiframe/Notiframe 2.py diff --git a/notiframe/Notiframe 2.py b/notiframe/Notiframe 2.py deleted file mode 100644 index c835d8c..0000000 --- a/notiframe/Notiframe 2.py +++ /dev/null @@ -1,88 +0,0 @@ -import uuid - -# Classes -# -class Manager(): - # Manager class to manage a notiframe session. - def __init__(self): - self.devices = [] - self.manager_id = gen_id() - - def add_device(self, name): #add parameters for Device class constructor - self.devices.append(Device(name)) - - def remove_device(self, dev_id): - for dev in self.devices: - if dev.device_id == dev_id: - self.devices.remove(dev) - break - -class Device(): - # Device class to contain a device's properties, layout and widgets - def __init__(self, name): - self.name = name - self.device_id = gen_id() - self.widgets = [] - -class Test(): - # Test class to test other classes and their functions. - def __init__(self): - #instantiate manager class - self.manager = Manager() - - def test_all(self): - manager_uuid = self.manager_uuid() - device_uuid = self.device_uuid() - add_device = self.add_device() - remove_device = self.remove_device() - - print("manager id is valid: " + str(manager_uuid)) - print("device id is valid: " + str(device_uuid)) - print("added device: " + str(add_device)) - print("removed device: " + str(remove_device)) - - # Note: Do function wrapper here for tests functions, to say "test_function_name" success/failure - def manager_uuid(self): - uuid_test = self.manager.manager_id - return self.is_valid_uuid(uuid_test) - - def device_uuid(self): - uuid_test = self.device.device_id - return self.is_valid_uuid(uuid_test) - - # Test if manager class's gen_id function produces a valid uuid - def is_valid_uuid(self, val): - try: - uuid.UUID(str(val)) - return True - except ValueError: - return False - - def add_device(self): - len1 = len(self.manager.devices) - self.manager.add_device("test") - len2 = len(self.manager.devices) - if len2 == len1 + 1: - return True - else: - return False - - def remove_device(self): - id = self.manager.devices[0].device_id - len1 = len(self.manager.devices) - self.manager.remove_device(id) - len2 = len(self.manager.devices) - if len2 == len1 - 1: - return True - else: - return False - - -# Global Functions -# -def gen_id(): - return uuid.uuid4() - - -test = Test() -test.test_all() diff --git a/notiframe/Notiframe.py b/notiframe/Notiframe.py index ae5e6d0..ba0e1c8 100644 --- a/notiframe/Notiframe.py +++ b/notiframe/Notiframe.py @@ -1,4 +1,7 @@ import uuid +import argparse + +test_mode = False # Classes #