Esempio n. 1
0
 def init_on_load(self):
     """Loads all necessary fields upon Action being loaded from database"""
     if not self.errors:
         errors = []
         try:
             self._run, self._arguments_api = get_app_action_api(self.app_name, self.action_name)
             get_app_action(self.app_name, self._run)
         except UnknownApp:
             errors.append('Unknown app {}'.format(self.app_name))
         except UnknownAppAction:
             errors.append('Unknown app action {}'.format(self.action_name))
         self.errors = errors
     self._last_status = None
     self._execution_id = 'default'
     self._resolved_device_id = -1
Esempio n. 2
0
 def init_on_load(self):
     """Loads all necessary fields upon Action being loaded from database"""
     if not self.errors:
         errors = []
         try:
             self._run, self._arguments_api = get_app_action_api(
                 self.app_name, self.action_name)
             get_app_action(self.app_name, self._run)
         except UnknownApp:
             errors.append('Unknown app {}'.format(self.app_name))
         except UnknownAppAction:
             errors.append('Unknown app action {}'.format(self.action_name))
         self.errors = errors
     self._last_status = None
     self._execution_id = 'default'
     self._resolved_device_id = -1
Esempio n. 3
0
 def validate(self):
     """Validates the object"""
     errors = []
     try:
         self._run, self._arguments_api = get_app_action_api(self.app_name, self.action_name)
         self._action_executable = get_app_action(self.app_name, self._run)
         if is_app_action_bound(self.app_name, self._run) and not self.device_id:
             message = 'App action is bound but no device ID was provided.'.format(self.name)
             errors.append(message)
         validate_app_action_parameters(self._arguments_api, self.arguments, self.app_name, self.action_name)
     except UnknownApp:
         errors.append('Unknown app {}'.format(self.app_name))
     except UnknownAppAction:
         errors.append('Unknown app action {}'.format(self.action_name))
     except InvalidArgument as e:
         errors.extend(e.errors)
     self.errors = errors
Esempio n. 4
0
 def validate(self):
     """Validates the object"""
     errors = []
     try:
         self._run, self._arguments_api = get_app_action_api(self.app_name, self.action_name)
         get_app_action(self.app_name, self._run)
         if is_app_action_bound(self.app_name, self._run) and not self.device_id:
             message = 'App action is bound but no device ID was provided.'.format(self.name)
             errors.append(message)
         validate_app_action_parameters(self._arguments_api, self.arguments, self.app_name, self.action_name)
     except UnknownApp:
         errors.append('Unknown app {}'.format(self.app_name))
     except UnknownAppAction:
         errors.append('Unknown app action {}'.format(self.action_name))
     except InvalidArgument as e:
         errors.extend(e.errors)
     self.errors = errors
Esempio n. 5
0
 def test_get_app_action_api_invalid_app(self):
     with self.assertRaises(UnknownApp):
         get_app_action_api('InvalidApp', 'pause')
Esempio n. 6
0
 def test_get_app_action_api_invalid_action(self):
     with self.assertRaises(UnknownAppAction):
         get_app_action_api('HelloWorld', 'invalid')
Esempio n. 7
0
 def test_get_app_action_api_invalid_app(self):
     with self.assertRaises(UnknownApp):
         get_app_action_api('InvalidApp', 'pause')
Esempio n. 8
0
 def test_get_app_action_api_invalid_action(self):
     with self.assertRaises(UnknownAppAction):
         get_app_action_api('HelloWorld', 'invalid')