def test_register_policy_invalid_policy_type_references(self): # Policy references an invalid (inexistent) policy type registrar = PolicyRegistrar() policy_path = os.path.join(get_fixtures_packs_base_path(), 'dummy_pack_1/policies/policy_2.yaml') expected_msg = 'Referenced policy_type "action.mock_policy_error" doesnt exist' self.assertRaisesRegexp(ValueError, expected_msg, registrar._register_policy, pack='dummy_pack_1', policy=policy_path)
def test_make_sure_policy_parameters_are_validated_during_register(self): # Policy where specified parameters fail schema validation registrar = PolicyRegistrar() policy_path = os.path.join(get_fixtures_packs_base_path(), 'dummy_pack_2/policies/policy_3.yaml') expected_msg = '100 is greater than the maximum of 5' self.assertRaisesRegexp(jsonschema.ValidationError, expected_msg, registrar._register_policy, pack='dummy_pack_2', policy=policy_path)