def test_commands(self): """ Items - commands""" print("--- test Command") # Global (Item) objects count global_objects_count = BackendElement().get_count() print(global_objects_count, "objects") print(BackendElement().get_cache()) # Base item Command.clean_cache() item = Command() print(item.__dict__) print(item) assert item assert len(Command.get_cache()) == 1 # Specific (Command) objects count and cache user_objects_count = Command.get_count() print(user_objects_count, " Command objects") print(item._cache) assert user_objects_count == 1 # Global objects count and cache did not changed assert global_objects_count == BackendElement().get_count() assert len(BackendElement().get_cache()) == global_objects_count # Only 1 User object assert item._count == 1 assert len(item._cache) == 1 assert len(Command.get_cache()) == 1 print(item) assert "%s" % item == "<command, id: command_0, name: Undefined command, status: unknown>" assert item._id == 'command_0' # Because no _id in the parameters ... assert item._type == 'command' assert item.name == 'Undefined command' assert item.status == 'unknown' assert item.status == 'unknown' print(item.get_html_state()) assert item.get_html_state( ) == '''<div class="item-state item_command " style="display: inline; font-size:0.9em;" data-item-id="%s" data-item-name="Undefined command" data-item-type="command" data-item-state="" title=""><span class="fa-stack " ><i class="fa fa-circle fa-stack-2x item_command"></i><i class="fa fa-bolt fa-stack-1x fa-inverse"></i></span><span></span></div>''' % item.id
def test_commands(self): """ Items - commands""" print("--- test Command") # Global (Item) objects count global_objects_count = BackendElement().get_count() print(global_objects_count, "objects") print(BackendElement().get_cache()) # Base item Command.clean_cache() item = Command() print(item.__dict__) print(item) assert item assert len(Command.get_cache()) == 1 # Specific (Command) objects count and cache user_objects_count = Command.get_count() print(user_objects_count, " Command objects") print(item._cache) assert user_objects_count == 1 # Global objects count and cache did not changed assert global_objects_count == BackendElement().get_count() assert len(BackendElement().get_cache()) == global_objects_count # Only 1 User object assert item._count == 1 assert len(item._cache) == 1 assert len(Command.get_cache()) == 1 print(item) assert "%s" % item == "<command, id: command_0, name: Undefined command, status: unknown>" assert item._id == 'command_0' # Because no _id in the parameters ... assert item._type == 'command' assert item.name == 'Undefined command' assert item.status == 'unknown' assert item.status == 'unknown' print(item.get_html_state()) assert item.get_html_state() == '''<div class="item-state item_command " style="display: inline; font-size:0.9em;" data-item-id="%s" data-item-name="Undefined command" data-item-type="command" data-item-state="" title=""><span class="fa-stack " ><i class="fa fa-circle fa-stack-2x item_command"></i><i class="fa fa-bolt fa-stack-1x fa-inverse"></i></span><span></span></div>''' % item.id
def event_handler(self): """Return linked object""" if not isinstance(self._linked_event_handler, BackendElement): return Command() return self._linked_event_handler
def snapshot_command(self): """Return linked object""" if not isinstance(self._linked_snapshot_command, BackendElement): return Command() return self._linked_snapshot_command