Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2013-05-04 05:12:03 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2013-05-04 05:12:03 (GMT)
commit2ca1d2d6fbc729bf1b871e71dffc67ede50ec7d0 (patch)
treeaacd3ad0958196737de6f9e407516676cd8af484
parent91c103c921311bccddedebf9f5d33a40ef17b131 (diff)
Strip host sugar version while checking for compatibility ranges
-rw-r--r--sugar_network/client/solver.py3
-rwxr-xr-xtests/units/client/injector.py47
2 files changed, 49 insertions, 1 deletions
diff --git a/sugar_network/client/solver.py b/sugar_network/client/solver.py
index 812bf1e..8322b00 100644
--- a/sugar_network/client/solver.py
+++ b/sugar_network/client/solver.py
@@ -151,7 +151,8 @@ def _load_feed(conn, context):
try:
# pylint: disable-msg=F0401
from jarabe import config
- for version in SUGAR_API_COMPATIBILITY.get(config.version) or []:
+ host_versin = '.'.join(config.version.split('.', 2)[:2])
+ for version in SUGAR_API_COMPATIBILITY.get(host_versin) or []:
feed.implement_sugar(version)
feed.name = context
return feed
diff --git a/tests/units/client/injector.py b/tests/units/client/injector.py
index 3d2d853..e0c9096 100755
--- a/tests/units/client/injector.py
+++ b/tests/units/client/injector.py
@@ -856,6 +856,53 @@ class InjectorTest(tests.Test):
],
solver.solve(conn, context))
+ def test_StripSugarVersion(self):
+ self.touch(('__init__.py', ''))
+ self.touch(('jarabe.py', 'class config: version = "0.94.1"'))
+ file_, pathname_, description_ = imp.find_module('jarabe', ['.'])
+ imp.load_module('jarabe', file_, pathname_, description_)
+
+ self.start_online_client([User, Context, Implementation])
+ conn = IPCClient()
+
+ context = conn.post(['context'], {
+ 'type': 'activity',
+ 'title': 'title',
+ 'summary': 'summary',
+ 'description': 'description',
+ })
+ conn.post(['context'], {
+ 'guid': 'sugar',
+ 'type': 'package',
+ 'title': 'title',
+ 'summary': 'summary',
+ 'description': 'description',
+ })
+
+ impl = conn.post(['implementation'], {
+ 'context': context,
+ 'license': 'GPLv3+',
+ 'version': '1',
+ 'stability': 'stable',
+ 'notes': '',
+ 'spec': {
+ '*-*': {
+ 'commands': {
+ 'activity': {
+ 'exec': 'echo',
+ },
+ },
+ 'requires': {
+ 'sugar': {},
+ },
+ },
+ }})
+ self.assertEqual([
+ {'name': 'title', 'version': '1', 'command': ['echo'], 'context': context, 'id': impl, 'stability': 'stable'},
+ {'name': 'sugar', 'version': '0.94', 'context': 'sugar', 'path': '/', 'id': 'sugar-0.94', 'stability': 'packaged'},
+ ],
+ solver.solve(conn, context))
+
class _FakeConnection(object):