diff options
-rw-r--r-- | sugar_network/resources/context.py | 42 | ||||
-rwxr-xr-x | tests/units/remote_mount.py | 2 |
2 files changed, 24 insertions, 20 deletions
diff --git a/sugar_network/resources/context.py b/sugar_network/resources/context.py index 60018a1..3c3827d 100644 --- a/sugar_network/resources/context.py +++ b/sugar_network/resources/context.py @@ -58,32 +58,36 @@ class Context(Resource): @ad.active_property(ad.BlobProperty, mime_type='image/png') def icon(self, value): - if not value: - if 'package' in self['type']: - return ad.PropertyMeta( - url='/static/images/package.png', - path=join(static.PATH, 'images', 'package.png'), - mime_type='image/png') - else: - return ad.PropertyMeta( - url='/static/images/missing.png', - path=join(static.PATH, 'images', 'missing.png'), - mime_type='image/png') - else: + if value: return value + if 'package' in self['type']: + return ad.PropertyMeta( + url='/static/images/package.png', + path=join(static.PATH, 'images', 'package.png'), + mime_type='image/png') + else: + return ad.PropertyMeta( + url='/static/images/missing.png', + path=join(static.PATH, 'images', 'missing.png'), + mime_type='image/png') @ad.active_property(ad.BlobProperty, mime_type='image/svg+xml') def artifact_icon(self, value): - if not value: - return ad.PropertyMeta( - url='/static/images/missing.svg', - path=join(static.PATH, 'images', 'missing.svg'), - mime_type='image/svg+xml') - return value + if value: + return value + return ad.PropertyMeta( + url='/static/images/missing.svg', + path=join(static.PATH, 'images', 'missing.svg'), + mime_type='image/svg+xml') @ad.active_property(ad.BlobProperty, mime_type='image/png') def preview(self, value): - return value + if value: + return value + return ad.PropertyMeta( + url='/static/images/missing.png', + path=join(static.PATH, 'images', 'missing.png'), + mime_type='image/png') @ad.active_property(prefix='K', typecast=bool, default=False) def keep(self, value): diff --git a/tests/units/remote_mount.py b/tests/units/remote_mount.py index 8ccc2c4..2544491 100755 --- a/tests/units/remote_mount.py +++ b/tests/units/remote_mount.py @@ -187,7 +187,7 @@ class RemoteMountTest(tests.Test): job.kill() self.assertEqual([ - {'document': 'context', 'event': 'update', 'guid': guid, 'seqno': 4}, + {'document': 'context', 'event': 'update', 'guid': guid, 'seqno': 5}, ], events) |