From abf481cab381a86d8a9c5607a131b56636081382 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 25 Sep 2012 05:48:06 +0900 Subject: refactored jsonconfig, included jsonschema validation and type casting. --- src/leap/base/tests/test_providers.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/leap/base/tests/test_providers.py') diff --git a/src/leap/base/tests/test_providers.py b/src/leap/base/tests/test_providers.py index d667a7e0..8d3b8847 100644 --- a/src/leap/base/tests/test_providers.py +++ b/src/leap/base/tests/test_providers.py @@ -1,15 +1,13 @@ +import copy import json try: import unittest2 as unittest except ImportError: import unittest - -# XXX FIXME -import logging -logging.basicConfig() - import os +import jsonschema + from leap import __branding as BRANDING from leap.testing.basetest import BaseLeapTest from leap.base import providers @@ -25,6 +23,7 @@ EXPECTED_DEFAULT_CONFIG = { u"services": [ u"eip" ], + u"languages": [u"en"], u"version": u"0.1.0" } @@ -84,6 +83,13 @@ class TestLeapProviderDefinition(BaseLeapTest): self.assertDictEqual(self.config, EXPECTED_DEFAULT_CONFIG) + def test_provider_validation(self): + self.definition.validate(self.config) + _config = copy.deepcopy(self.config) + _config['serial'] = 'aaa' + with self.assertRaises(jsonschema.ValidationError): + self.definition.validate(_config) + @unittest.skip def test_load_malformed_json_definition(self): raise NotImplementedError @@ -94,9 +100,6 @@ class TestLeapProviderDefinition(BaseLeapTest): # type cast raise NotImplementedError - def test_provider_validation(self): - self.definition.jsonvalidate(self.config) - class TestLeapProviderSet(BaseLeapTest): -- cgit v1.2.3