diff options
author | kali <kali@leap.se> | 2013-01-31 09:09:54 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2013-01-31 09:28:15 +0900 |
commit | da8a8ac4ebc62f7549d2927c41472561541abfa2 (patch) | |
tree | 730c6423a6a8cc1d0ef2b1345f1affcbb1c332c2 /src/leap/base/tests | |
parent | 8763866e0a4fc822f198e2e768993fdb9a38ef80 (diff) |
hide jsonschema exception in tests
Diffstat (limited to 'src/leap/base/tests')
-rw-r--r-- | src/leap/base/tests/test_providers.py | 6 | ||||
-rw-r--r-- | src/leap/base/tests/test_validation.py | 13 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/leap/base/tests/test_providers.py b/src/leap/base/tests/test_providers.py index f257f54d..92bc1f2f 100644 --- a/src/leap/base/tests/test_providers.py +++ b/src/leap/base/tests/test_providers.py @@ -6,9 +6,7 @@ except ImportError: import unittest import os -import jsonschema - -#from leap import __branding as BRANDING +from leap.base.pluggableconfig import ValidationError from leap.testing.basetest import BaseLeapTest from leap.base import providers @@ -96,7 +94,7 @@ class TestLeapProviderDefinition(BaseLeapTest): _config = copy.deepcopy(self.config) # bad type, raise validation error _config['domain'] = 111 - with self.assertRaises(jsonschema.ValidationError): + with self.assertRaises(ValidationError): self.definition.validate(_config) @unittest.skip diff --git a/src/leap/base/tests/test_validation.py b/src/leap/base/tests/test_validation.py index 87e99648..b45fbe3a 100644 --- a/src/leap/base/tests/test_validation.py +++ b/src/leap/base/tests/test_validation.py @@ -1,5 +1,6 @@ import copy import datetime +from functools import partial #import json try: import unittest2 as unittest @@ -7,8 +8,6 @@ except ImportError: import unittest import os -import jsonschema - from leap.base.config import JSONLeapConfig from leap.base import pluggableconfig from leap.testing.basetest import BaseLeapTest @@ -76,16 +75,18 @@ class TestJSONLeapConfigValidation(BaseLeapTest): def test_broken_int(self): _config = copy.deepcopy(SAMPLE_CONFIG_DICT) _config['prop_one'] = '1' - with self.assertRaises(jsonschema.ValidationError): - self.sampleconfig.validate(_config) + self.assertRaises( + pluggableconfig.ValidationError, + partial(self.sampleconfig.validate, _config)) def test_format_property(self): # JsonSchema Validator does not check the format property. # We should have to extend the Configuration class blah = copy.deepcopy(SAMPLE_CONFIG_DICT) blah['prop_uri'] = 'xxx' - with self.assertRaises(pluggableconfig.TypeCastException): - self.sampleconfig.validate(blah) + self.assertRaises( + pluggableconfig.TypeCastException, + partial(self.sampleconfig.validate, blah)) if __name__ == "__main__": |