def assertSimilarDevice(self, input_device: dict or str, created_device: dict or str): """ Checks that the createdDevice is the same as the input one, removing computed values as hid... It uses etag. :param input_device Input device needs all the float values to have, by default, ".0", or it won't work """ # todo make sure .0 doesn't crush in real program parsed_device = self.parse_device(input_device) with self.app.app_context(): from ereuse_devicehub.resources.device.domain import DeviceDomain self.assertTrue(DeviceDomain.seem_equal(self.full(self.DEVICES, parsed_device), self.full(self.DEVICES, created_device)))
def get_add_remove(self, device: dict, new_parent: dict): """ Get the changes (events) that will need to be triggered for the given device. Changes will we saved in the same device in the reserved key '_change'. The function doesn't execute any event per se or validate that the user can do it. :param device: The device must have an hid :param new_parent: """ if not device['new']: try: old_parent = ComponentDomain.get_parent(device['_id']) except DeviceNotFound: # The component exists but had no parent device, until now self.events.append_add(device, new_parent) else: if not DeviceDomain.seem_equal(old_parent, new_parent): self.events.append_remove(device, old_parent) self.events.append_add(device, new_parent)