summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-29 05:20:07 +0900
committerkali <kali@leap.se>2012-08-29 05:34:00 +0900
commit63c0b7aa3ded55426a834d0a5947fff798894c6b (patch)
tree185d734df3e49128ae41427c2d4aa474accea7e3 /src/leap
parent2be70492beb7212fdc585601c9e9939be6803acd (diff)
change slug to a property (read only)
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/base/providers.py20
-rw-r--r--src/leap/base/tests/test_providers.py15
2 files changed, 32 insertions, 3 deletions
diff --git a/src/leap/base/providers.py b/src/leap/base/providers.py
index e2075264..71ccf139 100644
--- a/src/leap/base/providers.py
+++ b/src/leap/base/providers.py
@@ -1,12 +1,26 @@
"""all dealing with leap-providers: definition files, updating"""
-from leap.base.config import JSONLeapConfig
+from leap.base import config as baseconfig
from leap.base import specs
-class LeapProviderDefinition(JSONLeapConfig):
- slug = 'definition.json'
+class LeapProviderDefinition(baseconfig.JSONLeapConfig):
spec = specs.leap_provider_spec
+ def get_slug(self):
+ provider_path = baseconfig.get_default_provider_path()
+ return baseconfig.get_config_file(
+ 'definition.json',
+ folder=provider_path)
+
+ def set_slug(self, *args, **kwargs):
+ raise AttributeError("you cannot set slug")
+
+ slug = property(get_slug, set_slug)
+
+ # TODO (MVS+)
+ # we will construct slug from providers/%s/definition.json
+ # where %s is domain name. we can get that on __init__
+
class LeapProviderSet(object):
# we gather them from the filesystem
diff --git a/src/leap/base/tests/test_providers.py b/src/leap/base/tests/test_providers.py
index 544355cc..4920be93 100644
--- a/src/leap/base/tests/test_providers.py
+++ b/src/leap/base/tests/test_providers.py
@@ -35,6 +35,21 @@ class TestLeapProviderDefinition(BaseLeapTest):
# tests
+ # XXX most of these tests can be made more abstract
+ # and moved to test_baseconfig *triangulate!*
+
+ def test_provider_slug_property(self):
+ slug = self.definition.slug
+ self.assertEquals(
+ slug,
+ os.path.join(
+ self.home,
+ '.config', 'leap', 'providers',
+ 'testprovider.example.org',
+ 'definition.json'))
+ with self.assertRaises(AttributeError):
+ self.definition.slug = 23
+
def test_provider_dump(self):
# check a good provider definition is dumped to disk
self.testfile = self.get_tempfile('test.json')