Example #1
0
    def test_register_action_with_no_params(self):
        registrar = actions_registrar.ActionsRegistrar()
        loader = fixtures_loader.FixturesLoader()
        action_file = loader.get_fixture_file_path_abs(
            'generic', 'actions', 'action-with-no-parameters.yaml')

        self.assertEqual(registrar._register_action('dummy', action_file), None)
Example #2
0
 def test_invalid_params_schema(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         'generic', 'actions', 'action-invalid-schema-params.yaml')
     try:
         registrar._register_action('dummy', action_file)
         self.fail('Invalid action schema. Should have failed.')
     except jsonschema.ValidationError:
         pass
Example #3
0
 def test_pack_name_missing(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         'generic', 'actions', 'action_3_pack_missing.json')
     registrar._register_action('dummy', action_file)
     action_name = None
     with open(action_file, 'r') as fd:
         content = json.load(fd)
         action_name = str(content['name'])
         action_db = Action.get_by_name(action_name)
         self.assertEqual(action_db.pack, 'dummy', 'Content pack must be ' +
                          'set to dummy')
         Action.delete(action_db)
Example #4
0
 def test_action_update(self):
     registrar = actions_registrar.ActionsRegistrar()
     loader = fixtures_loader.FixturesLoader()
     action_file = loader.get_fixture_file_path_abs(
         'generic', 'actions', 'action1.json')
     registrar._register_action('wolfpack', action_file)
     # try registering again. this should not throw errors.
     registrar._register_action('wolfpack', action_file)
     action_name = None
     with open(action_file, 'r') as fd:
         content = json.load(fd)
         action_name = str(content['name'])
         action_db = Action.get_by_name(action_name)
         self.assertEqual(action_db.pack, 'wolfpack', 'Content pack must be ' +
                          'set to wolfpack')
         Action.delete(action_db)