From 96940bbd7bff34eca9087421ea504d12958a3f7b Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 02 Oct 2012 06:27:56 +0000 Subject: Return stub images for missed "preview" in Context --- 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) -- cgit v0.9.1