summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-30 01:11:42 +0900
committerkali <kali@leap.se>2012-08-30 01:20:37 +0900
commite6483d20a5500e86b5fa4e7da63f911641b7e9dd (patch)
treeb1b2d07c1f105dad103f8fc8302d70ce50e4817f /src
parent1263cd7a3cfca81ae3e6976a489e2d3d4013d64b (diff)
fix config load method
it was not updating config dict
Diffstat (limited to 'src')
-rw-r--r--src/leap/base/config.py2
-rw-r--r--src/leap/eip/checks.py27
-rw-r--r--src/leap/eip/tests/test_checks.py13
3 files changed, 16 insertions, 26 deletions
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index c7871f22..45a5f08a 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -127,7 +127,7 @@ class JSONLeapConfig(BaseLeapConfig):
if fromfile is None:
fromfile = self.filename
- self._config.deserialize(fromfile)
+ self._config.config = self._config.deserialize(fromfile)
def get_config(self):
return self._config.config
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index b92ea706..4b2326a5 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -21,8 +21,8 @@ EIPConfigChecker
this is the first of 3 consecutive checks that we're implementing.
It is used from the eip conductor (a instance of EIPConnection that is
-managed from the QtApp), running run_all method before trying to call
-`connect` or any other of the state switching methods.
+managed from the QtApp), running `run_all` method before trying to call
+`connect` or any other of the state-changing methods.
It checks that the needed files are provided or can be discovered over the
net. Much of these tests are not specific to EIP module, and can be splitted
@@ -69,7 +69,7 @@ class EIPConfigChecker(object):
# TODO: get rid of check_default.
# check_complete should
- # be enough.
+ # be enough. but here to make early tests easier.
checker.check_default_eipconfig()
checker.check_is_there_default_provider()
@@ -103,15 +103,9 @@ class EIPConfigChecker(object):
default provider found on eip config.
This is catched by ui and runs FirstRunWizard (MVS+)
"""
- # if config is not None:
- # config = config
- # else: self.get_eipconfig
- # XXX parse EIPConfig.
- # XXX get default_provider.
+ if config is None:
+ config = self.eipconfig.get_config()
logger.debug('checking default provider')
- eipcfg = self._get_default_eipconfig_path()
- with open(eipcfg, 'r') as fp:
- config = json.load(fp)
provider = config.get('provider', None)
if provider is None:
raise eipexceptions.EIPMissingDefaultProvider
@@ -206,22 +200,11 @@ class EIPConfigChecker(object):
# private helpers
#
- def _get_default_eipconfig_path(self):
- return baseconfig.get_config_file(eipconstants.EIP_CONFIG)
-
def _is_there_default_eipconfig(self):
- #XXX
return self.eipconfig.exists()
- #return os.path.isfile(
- #self._get_default_eipconfig_path())
def _dump_default_eipconfig(self):
- #XXX self.eipconfig.save()
- logger.debug('saving eipconfig')
- #import ipdb;ipdb.set_trace()
self.eipconfig.save()
- #eipconfig.dump_default_eipconfig(
- #self._get_default_eipconfig_path())
def _get_provider_definition_uri(self, domain=None, path=None):
if domain is None:
diff --git a/src/leap/eip/tests/test_checks.py b/src/leap/eip/tests/test_checks.py
index e53a2a1d..5697ad10 100644
--- a/src/leap/eip/tests/test_checks.py
+++ b/src/leap/eip/tests/test_checks.py
@@ -93,19 +93,26 @@ class EIPCheckTest(BaseLeapTest):
# This error will be possible catched in a different
# place, when JSONConfig does validation of required fields.
- sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
+ # passing direct config
+ with self.assertRaises(eipexceptions.EIPMissingDefaultProvider):
+ checker.check_is_there_default_provider(config={})
+
+ # ok. now, messing with real files...
# blank out default_provider
+ sampleconfig = copy.copy(testdata.EIP_SAMPLE_JSON)
sampleconfig['provider'] = None
- eipcfg_path = checker._get_default_eipconfig_path()
+ eipcfg_path = checker.eipconfig.filename
with open(eipcfg_path, 'w') as fp:
json.dump(sampleconfig, fp)
with self.assertRaises(eipexceptions.EIPMissingDefaultProvider):
+ checker.eipconfig.load(fromfile=eipcfg_path)
checker.check_is_there_default_provider()
sampleconfig = testdata.EIP_SAMPLE_JSON
- eipcfg_path = checker._get_default_eipconfig_path()
+ #eipcfg_path = checker._get_default_eipconfig_path()
with open(eipcfg_path, 'w') as fp:
json.dump(sampleconfig, fp)
+ checker.eipconfig.load()
self.assertTrue(checker.check_is_there_default_provider())
def test_fetch_definition(self):