def transform_action_to_message(self, uuid, action, *args, **kwargs): """ Perform an action on UUID asset. An action must return a BridgeMessge, so this gets that and returns it. :param uuid: The asset to perform the action on. :type uuid: uuid :param action: The action to perform. :type action: str :param *args: The arguments for the action. :type args: list :param kwargs: The keyword arguments for the action. :type kwargs: dict :return: :class:`BridgeMessage` if successful or None if unsuccessful :rtype: :class:`BridgeMessage` """ asset = self.assets.get(uuid) if asset is not None: return perform_action(asset, action, *args, **kwargs) else: logging.error("{0} does not exist in this model, can not perform action {1}.".format(uuid, action)) return None
def test_create_onoffasset(self): asset = self.idiom.create_asset('Home Appliance', self.fake_real_id, 'ApplianceLinc V2') ret = perform_action(asset, 'turn_on') self.assertEquals('test_service', ret.to)
def test_off(self): ret = perform_action(self.asset, 'turn_off') self.assertEquals(ret.method, 'turn_off')
def test_action(self): perform_action(self.inner, 'floop') self.assertTrue(self.inner.x)