Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2014-03-11 12:25:59 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2014-03-11 12:25:59 (GMT)
commit47be127e9955013ddc5563013ded534cc3952ef1 (patch)
treeb3fba40ab90963e2ca6e5cdcc92ff14b4d0f33fa
parent41cb9e831db3d66973292fbdb4c13fb658ac9f59 (diff)
Revert multiple application commands
This time for the reason to run different commands in different environments like regular desktop, sugar shell.
-rw-r--r--sugar_network/db/blobs.py4
-rw-r--r--sugar_network/model/__init__.py2
-rw-r--r--sugar_network/node/model.py39
-rw-r--r--sugar_network/toolkit/spec.py18
-rwxr-xr-xtests/units/model/model.py15
-rwxr-xr-xtests/units/node/model.py215
-rwxr-xr-xtests/units/node/node.py143
-rwxr-xr-xtests/units/node/slave.py5
-rwxr-xr-xtests/units/toolkit/spec.py7
9 files changed, 280 insertions, 168 deletions
diff --git a/sugar_network/db/blobs.py b/sugar_network/db/blobs.py
index 52bc324..084ffde 100644
--- a/sugar_network/db/blobs.py
+++ b/sugar_network/db/blobs.py
@@ -36,6 +36,10 @@ class Blobs(object):
self._root = abspath(root)
self._seqno = seqno
+ @property
+ def root(self):
+ return self._root
+
def path(self, *args):
if len(args) == 1 and len(args[0]) == 40 and '.' not in args[0]:
return self._blob_path(args[0])
diff --git a/sugar_network/model/__init__.py b/sugar_network/model/__init__.py
index bd7405d..5068a63 100644
--- a/sugar_network/model/__init__.py
+++ b/sugar_network/model/__init__.py
@@ -179,7 +179,7 @@ def load_bundle(blob, context=None, initial=False, extra_deps=None):
release['stability'] = spec['stability']
if spec['license'] is not EMPTY_LICENSE:
release['license'] = spec['license']
- release['command'] = spec.command
+ release['commands'] = spec.commands
release['requires'] = spec.requires
release['bundles'] = {
'*-*': {
diff --git a/sugar_network/node/model.py b/sugar_network/node/model.py
index 90e50c2..559f6b4 100644
--- a/sugar_network/node/model.py
+++ b/sugar_network/node/model.py
@@ -105,12 +105,13 @@ class Context(base_context.Context):
return value
-def solve(volume, top_context, lsb_id=None, lsb_release=None,
+def solve(volume, top_context, command=None, lsb_id=None, lsb_release=None,
stability=None, requires=None):
top_context = volume['context'][top_context]
- top_stability = stability or ['stable']
- if isinstance(top_stability, basestring):
- top_stability = [top_stability]
+ if stability is None:
+ stability = ['stable']
+ if isinstance(stability, basestring):
+ stability = [stability]
top_cond = []
top_requires = {}
if isinstance(requires, basestring):
@@ -129,17 +130,16 @@ def solve(volume, top_context, lsb_id=None, lsb_release=None,
clauses = []
_logger.debug('Solve %r lsb_id=%r lsb_release=%r stability=%r requires=%r',
- top_context.guid, lsb_id, lsb_release, top_stability, top_requires)
+ top_context.guid, lsb_id, lsb_release, stability, top_requires)
def rate_release(digest, release):
- return [_STABILITY_RATES.get(release['stability']) or 0,
+ return [command in release['commands'],
+ _STABILITY_RATES.get(release['stability']) or 0,
release['version'],
digest,
]
- def add_deps(context, v_usage, deps):
- if top_requires and context.guid == top_context.guid:
- deps.update(top_requires)
+ def add_deps(v_usage, deps):
for dep, cond in deps.items():
dep_clause = [-v_usage]
for v_release in add_context(dep):
@@ -178,7 +178,7 @@ def solve(volume, top_context, lsb_id=None, lsb_release=None,
if 'value' not in release:
continue
release = release['value']
- if release['stability'] not in top_stability or \
+ if release['stability'] not in stability or \
context.guid == top_context.guid and \
not spec.ensure(release['version'], top_cond):
continue
@@ -187,12 +187,27 @@ def solve(volume, top_context, lsb_id=None, lsb_release=None,
digest = release[-1]
release = releases[digest]['value']
release_info = {'version': release['version'], 'blob': digest}
+ blob = volume.blobs.get(digest)
+ if blob is not None:
+ release_info['size'] = blob.size
+ unpack_size = release['bundles']['*-*'].get('unpack_size')
+ if unpack_size is not None:
+ release_info['unpack_size'] = unpack_size
+ requires = release.get('requires') or {}
+ if top_requires and context.guid == top_context.guid:
+ requires.update(top_requires)
if context.guid == top_context.guid:
- release_info['command'] = release['command']
+ cmd = release['commands'].get(command)
+ if cmd is None:
+ cmd_name, cmd = release['commands'].items()[0]
+ else:
+ cmd_name = command
+ release_info['command'] = (cmd_name, cmd['exec'])
+ requires.update(cmd.get('requires') or {})
v_release = len(varset)
varset.append((context.guid, release_info))
clause.append(v_release)
- add_deps(context, v_release, release.get('requires') or {})
+ add_deps(v_release, requires)
if clause:
context_clauses[context.guid] = clause
diff --git a/sugar_network/toolkit/spec.py b/sugar_network/toolkit/spec.py
index a8489ce..bd852d4 100644
--- a/sugar_network/toolkit/spec.py
+++ b/sugar_network/toolkit/spec.py
@@ -193,7 +193,7 @@ class Spec(object):
def __init__(self, spec=None, root=None):
self.path = None
- self.command = None
+ self.commands = {}
self.bindings = set()
self.requires = {}
self.build_requires = []
@@ -276,8 +276,7 @@ class Spec(object):
if section_type == 'Activity':
self._new_activity(section, requires)
elif section_type == 'Application':
- cmd_name = section.split(':')[-1] if ':' in section else 'run'
- self._new_command(section, requires, cmd_name)
+ self._new_command(section, requires)
self.applications.append(_Application(self._config, section))
elif section_type == 'Library':
enforce(':' not in section, '[Library] should be singular')
@@ -347,13 +346,16 @@ class Spec(object):
for i in self.applications:
i.name = '-'.join(i.section.split(':')[1:])
- def _new_command(self, section, requires, name):
- enforce(self.command is None, 'Only one command is allowed')
+ def _new_command(self, section, requires):
cmdline = self._get(section, 'exec')
enforce(cmdline,
'Option "exec" should exist for [%s] section', section)
- self.command = cmdline
- self.requires.update(requires)
+ name = section.split(':')[-1] if ':' in section else section.lower()
+ command = self.commands[name] = {'exec': cmdline}
+ if ':' in section:
+ command['requires'] = requires
+ else:
+ self.requires.update(requires)
def _new_activity(self, section, requires):
enforce(':' not in section, '[Activity] should be singular')
@@ -372,7 +374,7 @@ class Spec(object):
enforce(self._get(section, key),
'Option "%s" should exist for activities', key)
- self._new_command(section, requires, 'activity')
+ self._new_command(section, requires)
self.activity = _Activity(self._config, section)
def _new_archive(self, section):
diff --git a/tests/units/model/model.py b/tests/units/model/model.py
index 10ca599..a180f30 100755
--- a/tests/units/model/model.py
+++ b/tests/units/model/model.py
@@ -8,7 +8,6 @@ import mimetypes
from __init__ import tests
from sugar_network import db
-from sugar_network.db import blobs
from sugar_network.model import load_bundle
from sugar_network.model.post import Post
from sugar_network.client import IPCConnection, Connection, keyfile
@@ -40,6 +39,7 @@ class ModelTest(tests.Test):
def test_load_bundle_Activity(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -74,6 +74,7 @@ class ModelTest(tests.Test):
'content-type': 'application/vnd.olpc-sugar',
'content-disposition': 'attachment; filename="Activity-1%s"' % (mimetypes.guess_extension('application/vnd.olpc-sugar') or ''),
'content-length': str(len(bundle)),
+ 'x-seqno': '4',
}, blobs.get(blob.digest))
self.assertEqual('bundle_id', context)
self.assertEqual([[1], 0], release['version'])
@@ -107,6 +108,7 @@ class ModelTest(tests.Test):
def test_load_bundle_NonActivity(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -127,6 +129,7 @@ class ModelTest(tests.Test):
'content-type': 'application/pdf',
'content-disposition': 'attachment; filename="NonActivity-2.pdf"',
'content-length': str(len(bundle)),
+ 'x-seqno': '4',
}, blobs.get(blob.digest))
self.assertEqual('bundle_id', context)
self.assertEqual([[2], 0], release['version'])
@@ -146,6 +149,7 @@ class ModelTest(tests.Test):
def test_load_bundle_ReuseActivityLicense(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -194,6 +198,7 @@ class ModelTest(tests.Test):
def test_load_bundle_ReuseNonActivityLicense(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -234,6 +239,7 @@ class ModelTest(tests.Test):
def test_load_bundle_WrontContextType(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -269,6 +275,7 @@ class ModelTest(tests.Test):
def test_load_bundle_MissedContext(self):
volume = self.start_master()
+ blobs = volume.blobs
volume['user'].create({'guid': tests.UID, 'name': 'user', 'pubkey': tests.PUBKEY})
conn = Connection(auth=http.SugarAuth(keyfile.value))
@@ -290,6 +297,7 @@ class ModelTest(tests.Test):
def test_load_bundle_CreateContext(self):
volume = self.start_master()
+ blobs = volume.blobs
volume['user'].create({'guid': tests.UID, 'name': 'user', 'pubkey': tests.PUBKEY})
conn = Connection(auth=http.SugarAuth(keyfile.value))
@@ -336,6 +344,7 @@ class ModelTest(tests.Test):
def test_load_bundle_UpdateContext(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -409,6 +418,7 @@ class ModelTest(tests.Test):
def test_load_bundle_3rdPartyRelease(self):
i18n._default_langs = ['en']
volume = self.start_master()
+ blobs = volume.blobs
volume['user'].create({'guid': tests.UID2, 'name': 'user2', 'pubkey': tests.PUBKEY2})
conn = Connection(auth=http.SugarAuth(keyfile.value))
@@ -469,6 +479,7 @@ class ModelTest(tests.Test):
def test_load_bundle_PopulateRequires(self):
volume = self.start_master()
+ blobs = volume.blobs
conn = Connection(auth=http.SugarAuth(keyfile.value))
conn.post(['context'], {
@@ -519,7 +530,7 @@ class ModelTest(tests.Test):
this.request = Request(method='POST', path=['context', context])
aggid = conn.post(['context', context, 'releases'], -1)
self.assertEqual({
- aggid: {'seqno': 3, 'value': -1, 'author': {tests.UID: {'role': 3, 'name': tests.UID, 'order': 0}}},
+ aggid: {'seqno': 4, 'value': -1, 'author': {tests.UID: {'role': 3, 'name': tests.UID, 'order': 0}}},
}, volume['context'][context]['releases'])
diff --git a/tests/units/node/model.py b/tests/units/node/model.py
index 36937dc..024c148 100755
--- a/tests/units/node/model.py
+++ b/tests/units/node/model.py
@@ -263,24 +263,24 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'commands1'}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0], 'command': 'commands2'}},
- '3': {'value': {'stability': 'stable', 'version': [[3], 0], 'command': 'commands3'}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 1}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 2}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 3}}}},
},
})
self.assertEqual(
- {context: {'command': 'commands3', 'blob': '3', 'version': [[3], 0]}},
+ {context: {'command': ('activity', 3), 'blob': '3', 'version': [[3], 0]}},
model.solve(volume, context))
context = volume['context'].create({
'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '3': {'value': {'stability': 'stable', 'version': [[3], 0], 'command': 'commands3'}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0], 'command': 'commands2'}},
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'commands1'}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 3}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 2}}}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 1}}}},
},
})
self.assertEqual(
- {context: {'command': 'commands3', 'blob': '3', 'version': [[3], 0]}},
+ {context: {'command': ('activity', 3), 'blob': '3', 'version': [[3], 0]}},
model.solve(volume, context))
def test_solve_SortByStability(self):
@@ -289,13 +289,13 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'developer', 'version': [[1], 0], 'command': 'commands1'}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0], 'command': 'commands2'}},
- '3': {'value': {'stability': 'buggy', 'version': [[3], 0], 'command': 'commands3'}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'developer', 'version': [[1], 0], 'commands': {'activity': {'exec': 1}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 2}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'buggy', 'version': [[3], 0], 'commands': {'activity': {'exec': 3}}}},
},
})
self.assertEqual(
- {context: {'command': 'commands2', 'blob': '2', 'version': [[2], 0]}},
+ {context: {'command': ('activity', 2), 'blob': '2', 'version': [[2], 0]}},
model.solve(volume, context))
def test_solve_CollectDeps(self):
@@ -305,142 +305,181 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
'1': {'value': {
- 'stability': 'stable',
+ 'bundles': {'*-*': {}}, 'stability': 'stable',
'version': [[1], 0],
'requires': spec.parse_requires('context2; context4'),
- 'command': 'command',
+ 'commands': {'activity': {'exec': 'command'}},
}},
},
})
volume['context'].create({
'guid': 'context2', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
'2': {'value': {
- 'stability': 'stable',
+ 'bundles': {'*-*': {}}, 'stability': 'stable',
'version': [[2], 0],
+ 'commands': {'activity': {'exec': 0}},
'requires': spec.parse_requires('context3'),
}},
},
})
volume['context'].create({
'guid': 'context3', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '3': {'value': {'stability': 'stable', 'version': [[3], 0]}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
volume['context'].create({
'guid': 'context4', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '4': {'value': {'stability': 'stable', 'version': [[4], 0]}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[4], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
self.assertEqual({
- 'context1': {'blob': '1', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '1', 'version': [[1], 0], 'command': ('activity', 'command')},
'context2': {'blob': '2', 'version': [[2], 0]},
'context3': {'blob': '3', 'version': [[3], 0]},
'context4': {'blob': '4', 'version': [[4], 0]},
},
model.solve(volume, 'context1'))
+ def test_solve_CommandDeps(self):
+ volume = db.Volume('master', [Context])
+ this.volume = volume
+
+ volume['context'].create({
+ 'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
+ '1': {'value': {
+ 'bundles': {'*-*': {}}, 'stability': 'stable',
+ 'version': [[1], 0],
+ 'requires': [],
+ 'commands': {
+ 'activity': {'exec': 1, 'requires': spec.parse_requires('context2')},
+ 'application': {'exec': 2},
+ },
+ }},
+ },
+ })
+ volume['context'].create({
+ 'guid': 'context2', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
+ '2': {'value': {
+ 'bundles': {'*-*': {}}, 'stability': 'stable',
+ 'version': [[2], 0],
+ 'commands': {'activity': {'exec': 0}},
+ 'requires': [],
+ }},
+ },
+ })
+
+ self.assertEqual({
+ 'context1': {'blob': '1', 'version': [[1], 0], 'command': ('activity', 1)},
+ 'context2': {'blob': '2', 'version': [[2], 0]},
+ },
+ model.solve(volume, 'context1', command='activity'))
+ self.assertEqual({
+ 'context1': {'blob': '1', 'version': [[1], 0], 'command': ('application', 2)},
+ },
+ model.solve(volume, 'context1', command='application'))
+
def test_solve_DepConditions(self):
volume = db.Volume('master', [Context])
this.volume = volume
volume['context'].create({
'guid': 'dep', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0]}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0]}},
- '3': {'value': {'stability': 'stable', 'version': [[3], 0]}},
- '4': {'value': {'stability': 'stable', 'version': [[4], 0]}},
- '5': {'value': {'stability': 'stable', 'version': [[5], 0]}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 0}}}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[4], 0], 'commands': {'activity': {'exec': 0}}}},
+ '5': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[5], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep < 3'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '2', 'version': [[2], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep <= 3'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '3', 'version': [[3], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep > 2'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '5', 'version': [[5], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep >= 2'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '5', 'version': [[5], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep > 2; dep < 5'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '4', 'version': [[4], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep > 2; dep <= 3'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '3', 'version': [[3], 0]},
},
model.solve(volume, 'context1'))
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep = 1'),
}},
},
})
self.assertEqual({
- 'context1': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context1': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '1', 'version': [[1], 0]},
},
model.solve(volume, 'context1'))
@@ -451,29 +490,33 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'context1', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '6': {'value': {'stability': 'stable', 'version': [[1], 0], 'requires': spec.parse_requires('context4=1'), 'command': 'commands6'}},
- '1': {'value': {'stability': 'stable', 'version': [[2], 0], 'requires': spec.parse_requires('context2'), 'command': 'commands1'}},
+ '6': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}},
+ 'requires': spec.parse_requires('context4=1'), 'commands': {'activity': {'exec': 6}}}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}},
+ 'requires': spec.parse_requires('context2'), 'commands': {'activity': {'exec': 1}}}},
},
})
volume['context'].create({
'guid': 'context2', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '2': {'value': {'stability': 'stable', 'version': [[1], 0], 'requires': spec.parse_requires('context3; context4=1')}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}},
+ 'requires': spec.parse_requires('context3; context4=1')}},
},
})
volume['context'].create({
'guid': 'context3', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '3': {'value': {'stability': 'stable', 'version': [[1], 0], 'requires': spec.parse_requires('context4=2')}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}},
+ 'requires': spec.parse_requires('context4=2')}},
},
})
volume['context'].create({
'guid': 'context4', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '4': {'value': {'stability': 'stable', 'version': [[2], 0]}},
- '5': {'value': {'stability': 'stable', 'version': [[1], 0]}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}}}},
+ '5': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
self.assertEqual({
- 'context1': {'blob': '6', 'version': [[1], 0], 'command': 'commands6'},
+ 'context1': {'blob': '6', 'version': [[1], 0], 'command': ('activity', 6)},
'context4': {'blob': '5', 'version': [[1], 0]},
},
model.solve(volume, 'context1'))
@@ -484,11 +527,11 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'dep', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0]}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0]}},
- '3': {'value': {'stability': 'stable', 'version': [[3], 0]}},
- '4': {'value': {'stability': 'stable', 'version': [[4], 0]}},
- '5': {'value': {'stability': 'stable', 'version': [[5], 0]}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 0}}}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[4], 0], 'commands': {'activity': {'exec': 0}}}},
+ '5': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[5], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
@@ -496,13 +539,13 @@ class ModelTest(tests.Test):
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {},
'dependencies': 'dep=2',
'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires(''),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '2', 'version': [[2], 0]},
},
model.solve(volume, 'context'))
@@ -511,13 +554,13 @@ class ModelTest(tests.Test):
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {},
'dependencies': 'dep<5',
'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep>1'),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '4', 'version': [[4], 0]},
},
model.solve(volume, 'context'))
@@ -526,13 +569,13 @@ class ModelTest(tests.Test):
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {},
'dependencies': 'dep<4',
'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep<5'),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '3', 'version': [[3], 0]},
},
model.solve(volume, 'context'))
@@ -543,48 +586,48 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'dep', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0]}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0]}},
- '3': {'value': {'stability': 'stable', 'version': [[3], 0]}},
- '4': {'value': {'stability': 'stable', 'version': [[4], 0]}},
- '5': {'value': {'stability': 'stable', 'version': [[5], 0]}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 0}}}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[4], 0], 'commands': {'activity': {'exec': 0}}}},
+ '5': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[5], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires(''),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
},
model.solve(volume, 'context'))
volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep>1'),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '5', 'version': [[5], 0]},
},
model.solve(volume, 'context'))
volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep<5'),
}},
},
})
self.assertEqual({
- 'context': {'blob': '10', 'version': [[1], 0], 'command': 'command'},
+ 'context': {'blob': '10', 'version': [[1], 0], 'command': ('activity', 'command')},
'dep': {'blob': '4', 'version': [[4], 0]},
},
model.solve(volume, 'context'))
@@ -596,11 +639,11 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'dep', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0]}},
- '2': {'value': {'stability': 'stable', 'version': [[2], 0]}},
- '3': {'value': {'stability': 'stable', 'version': [[3], 0]}},
- '4': {'value': {'stability': 'stable', 'version': [[4], 0]}},
- '5': {'value': {'stability': 'stable', 'version': [[5], 0]}},
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[2], 0], 'commands': {'activity': {'exec': 0}}}},
+ '3': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[3], 0], 'commands': {'activity': {'exec': 0}}}},
+ '4': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[4], 0], 'commands': {'activity': {'exec': 0}}}},
+ '5': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[5], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
@@ -612,7 +655,7 @@ class ModelTest(tests.Test):
volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '10': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '10': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep=0'),
}},
},
@@ -626,7 +669,7 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('package'),
}},
},
@@ -639,25 +682,25 @@ class ModelTest(tests.Test):
},
})
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package': {'packages': ['pkg1', 'pkg2'], 'version': [[1], 0]},
},
model.solve(volume, context, lsb_id='Ubuntu', lsb_release='10.04'))
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('dep; package'),
}},
},
})
volume['context'].create({
'guid': 'dep', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '2': {'value': {'stability': 'stable', 'version': [[1], 0]}},
+ '2': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 0}}}},
},
})
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'dep': {'blob': '2', 'version': [[1], 0]},
'package': {'packages': ['pkg1', 'pkg2'], 'version': [[1], 0]},
},
@@ -670,7 +713,7 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('package1'),
}},
},
@@ -681,14 +724,14 @@ class ModelTest(tests.Test):
},
})
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package1': {'packages': ['bin1', 'bin2', 'devel1', 'devel2'], 'version': []},
},
model.solve(volume, context, lsb_id='Ubuntu'))
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('package2'),
}},
},
@@ -702,7 +745,7 @@ class ModelTest(tests.Test):
},
})
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package2': {'packages': ['bin'], 'version': []},
},
model.solve(volume, context, lsb_id='Ubuntu', lsb_release='fake'))
@@ -714,7 +757,7 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('package1'),
}},
},
@@ -729,17 +772,17 @@ class ModelTest(tests.Test):
},
})
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package1': {'packages': ['pkg1'], 'version': []},
},
model.solve(volume, context))
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package1': {'packages': ['pkg1'], 'version': []},
},
model.solve(volume, context, lsb_id='Fake'))
self.assertEqual({
- 'context': {'blob': '1', 'command': 'command', 'version': [[1], 0]},
+ 'context': {'blob': '1', 'command': ('activity', 'command'), 'version': [[1], 0]},
'package1': {'packages': ['pkg1'], 'version': []},
},
model.solve(volume, context, lsb_id='Fake', lsb_release='fake'))
@@ -751,7 +794,7 @@ class ModelTest(tests.Test):
context = volume['context'].create({
'guid': 'context', 'type': ['activity'], 'title': {}, 'summary': {}, 'description': {}, 'releases': {
- '1': {'value': {'stability': 'stable', 'version': [[1], 0], 'command': 'command',
+ '1': {'value': {'bundles': {'*-*': {}}, 'stability': 'stable', 'version': [[1], 0], 'commands': {'activity': {'exec': 'command'}},
'requires': spec.parse_requires('package'),
}},
},
diff --git a/tests/units/node/node.py b/tests/units/node/node.py
index 36c6285..a8c68e8 100755
--- a/tests/units/node/node.py
+++ b/tests/units/node/node.py
@@ -504,7 +504,7 @@ class NodeTest(tests.Test):
'version': [[1], 0],
'requires': {},
'bundles': {'*-*': {'blob': str(hashlib.sha1(bundle).hexdigest()), 'unpack_size': len(activity_info) + len(changelog)}},
- 'command': 'true',
+ 'commands': {'activity': {'exec': 'true'}},
'stability': 'developer',
},
},
@@ -526,29 +526,31 @@ class NodeTest(tests.Test):
volume = self.start_master()
conn = http.Connection(api.value, http.SugarAuth(keyfile.value))
- activity_file = json.load(conn.request('POST', ['context'],
- self.zips(('topdir/activity/activity.info', '\n'.join([
- '[Activity]',
- 'name = activity',
- 'bundle_id = activity',
- 'exec = true',
- 'icon = icon',
- 'activity_version = 1',
- 'license = Public Domain',
- 'requires = dep; package',
- ]))),
- params={'cmd': 'submit', 'initial': True}).raw)
- dep_file = json.load(conn.request('POST', ['context'],
- self.zips(('topdir/activity/activity.info', '\n'.join([
- '[Activity]',
- 'name = dep',
- 'bundle_id = dep',
- 'exec = true',
- 'icon = icon',
- 'activity_version = 2',
- 'license = Public Domain',
- ]))),
- params={'cmd': 'submit', 'initial': True}).raw)
+ activity_unpack = '\n'.join([
+ '[Activity]',
+ 'name = activity',
+ 'bundle_id = activity',
+ 'exec = true',
+ 'icon = icon',
+ 'activity_version = 1',
+ 'license = Public Domain',
+ 'requires = dep; package',
+ ])
+ activity_pack = self.zips(('topdir/activity/activity.info', activity_unpack))
+ activity_blob = json.load(conn.request('POST', ['context'], activity_pack, params={'cmd': 'submit', 'initial': True}).raw)
+
+ dep_unpack = '\n'.join([
+ '[Activity]',
+ 'name = dep',
+ 'bundle_id = dep',
+ 'exec = true',
+ 'icon = icon',
+ 'activity_version = 2',
+ 'license = Public Domain',
+ ])
+ dep_pack = self.zips(('topdir/activity/activity.info', dep_unpack))
+ dep_blob = json.load(conn.request('POST', ['context'], dep_pack, params={'cmd': 'submit', 'initial': True}).raw)
+
this.call(method='POST', path=['context'], principal=tests.UID, content={
'guid': 'package',
'type': 'package',
@@ -559,9 +561,23 @@ class NodeTest(tests.Test):
conn.put(['context', 'package', 'releases', '*'], {'binary': ['package.bin']})
self.assertEqual({
- 'activity': {'blob': activity_file, 'command': 'true', 'version': [[1], 0]},
- 'dep': {'blob': dep_file, 'version': [[2], 0]},
- 'package': {'packages': ['package.bin'], 'version': []},
+ 'activity': {
+ 'blob': activity_blob,
+ 'command': ['activity', 'true'],
+ 'version': [[1], 0],
+ 'size': len(activity_pack),
+ 'unpack_size': len(activity_unpack),
+ },
+ 'dep': {
+ 'blob': dep_blob,
+ 'version': [[2], 0],
+ 'size': len(dep_pack),
+ 'unpack_size': len(dep_unpack),
+ },
+ 'package': {
+ 'packages': ['package.bin'],
+ 'version': [],
+ },
},
conn.get(['context', 'activity'], cmd='solve'))
@@ -569,19 +585,20 @@ class NodeTest(tests.Test):
volume = self.start_master()
conn = http.Connection(api.value, http.SugarAuth(keyfile.value))
- activity_file = json.load(conn.request('POST', ['context'],
- self.zips(('topdir/activity/activity.info', '\n'.join([
- '[Activity]',
- 'name = activity',
- 'bundle_id = activity',
- 'exec = true',
- 'icon = icon',
- 'activity_version = 1',
- 'license = Public Domain',
- 'stability = developer',
- ]))),
- params={'cmd': 'submit', 'initial': True}).raw)
- activity_fake_file = json.load(conn.request('POST', ['context'],
+ activity_unpack = '\n'.join([
+ '[Activity]',
+ 'name = activity',
+ 'bundle_id = activity',
+ 'exec = true',
+ 'icon = icon',
+ 'activity_version = 1',
+ 'license = Public Domain',
+ 'stability = developer',
+ ])
+ activity_pack = self.zips(('topdir/activity/activity.info', activity_unpack))
+ activity_blob = json.load(conn.request('POST', ['context'], activity_pack, params={'cmd': 'submit', 'initial': True}).raw)
+
+ activity_fake_blob = json.load(conn.request('POST', ['context'],
self.zips(('topdir/activity/activity.info', '\n'.join([
'[Activity]',
'name = activity',
@@ -592,18 +609,20 @@ class NodeTest(tests.Test):
'license = Public Domain',
]))),
params={'cmd': 'submit'}).raw)
- dep_file = json.load(conn.request('POST', ['context'],
- self.zips(('topdir/activity/activity.info', '\n'.join([
- '[Activity]',
- 'name = dep',
- 'bundle_id = dep',
- 'exec = true',
- 'icon = icon',
- 'activity_version = 2',
- 'license = Public Domain',
- 'stability = developer',
- ]))),
- params={'cmd': 'submit', 'initial': True}).raw)
+
+ dep_unpack = '\n'.join([
+ '[Activity]',
+ 'name = dep',
+ 'bundle_id = dep',
+ 'exec = true',
+ 'icon = icon',
+ 'activity_version = 2',
+ 'license = Public Domain',
+ 'stability = developer',
+ ])
+ dep_pack = self.zips(('topdir/activity/activity.info', dep_unpack))
+ dep_blob = json.load(conn.request('POST', ['context'], dep_pack, params={'cmd': 'submit', 'initial': True}).raw)
+
this.call(method='POST', path=['context'], principal=tests.UID, content={
'guid': 'package',
'type': 'package',
@@ -618,9 +637,23 @@ class NodeTest(tests.Test):
}}})
self.assertEqual({
- 'activity': {'blob': activity_file, 'command': 'true', 'version': [[1], 0]},
- 'dep': {'blob': dep_file, 'version': [[2], 0]},
- 'package': {'packages': ['package.bin'], 'version': [[1], 0]},
+ 'activity': {
+ 'blob': activity_blob,
+ 'command': ['activity', 'true'],
+ 'version': [[1], 0],
+ 'size': len(activity_pack),
+ 'unpack_size': len(activity_unpack),
+ },
+ 'dep': {
+ 'blob': dep_blob,
+ 'version': [[2], 0],
+ 'size': len(dep_pack),
+ 'unpack_size': len(dep_unpack),
+ },
+ 'package': {
+ 'packages': ['package.bin'],
+ 'version': [[1], 0],
+ },
},
conn.get(['context', 'activity'], cmd='solve',
stability='developer', lsb_id='Ubuntu', lsb_release='10.04', requires=['dep', 'package']))
diff --git a/tests/units/node/slave.py b/tests/units/node/slave.py
index 6e75602..184da43 100755
--- a/tests/units/node/slave.py
+++ b/tests/units/node/slave.py
@@ -263,6 +263,7 @@ class SlaveTest(tests.Test):
({'ack': [[101, 103]], 'from': '127.0.0.1:7777', 'packet': 'ack', 'ranges': [[1, 3]], 'to': self.slave_routes.guid}, [
]),
({'from': self.slave_routes.guid, 'packet': 'push', 'to': '127.0.0.1:7777'}, [
+ {'resource': 'document'},
]),
({'from': self.slave_routes.guid, 'packet': 'pull', 'ranges': [[3, 100], [104, None]], 'to': '127.0.0.1:7777'}, [
]),
@@ -314,11 +315,12 @@ class SlaveTest(tests.Test):
{'commit': [[1, 2]]},
]),
({'from': self.slave_routes.guid, 'packet': 'push', 'to': '127.0.0.1:7777'}, [
+ {'resource': 'document'},
]),
({'from': self.slave_routes.guid, 'packet': 'pull', 'ranges': [[3, None]], 'to': '127.0.0.1:7777'}, [
]),
]),
- sorted([(packet.header, [i for i in packet]) for packet in parcel.decode_dir('sync')]))
+ sorted([(packet.header, [dict(i) for i in packet]) for packet in parcel.decode_dir('sync')]))
def test_offline_sync_ImportAck(self):
slave = Connection('http://127.0.0.1:8888', auth=http.SugarAuth(keyfile.value))
@@ -382,6 +384,7 @@ class SlaveTest(tests.Test):
({'from': self.slave_routes.guid, 'packet': 'request', 'to': '127.0.0.1:7777', 'origin': 'another-slave', 'ranges': [[1, 1]]}, [
]),
({'from': self.slave_routes.guid, 'packet': 'push', 'to': '127.0.0.1:7777'}, [
+ {'resource': 'document'},
]),
({'from': self.slave_routes.guid, 'packet': 'pull', 'ranges': [[1, None]], 'to': '127.0.0.1:7777'}, [
]),
diff --git a/tests/units/toolkit/spec.py b/tests/units/toolkit/spec.py
index 7c7188e..66cb2b3 100755
--- a/tests/units/toolkit/spec.py
+++ b/tests/units/toolkit/spec.py
@@ -78,9 +78,10 @@ class SpecTest(tests.Test):
self.assertEqual('stable', recipe['stability'])
self.assertEqual(['terminal', 'console'], recipe['tags'])
self.assertEqual(['image/png', 'image/svg+xml'], recipe['mime_types'])
- self.assertEqual(
- 'sugar-activity terminal.TerminalActivity',
- recipe.command)
+ self.assertEqual({
+ 'activity': {'exec': 'sugar-activity terminal.TerminalActivity'},
+ },
+ recipe.commands)
self.assertEqual({
'sugar': [([0], [[0, 94], 0])],
},