summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2014-10-06 12:05:49 -0300
committerVictor Shyba <victor.shyba@gmail.com>2014-10-06 12:05:49 -0300
commit88abefd3e62fb65a08dde62a7d7e4ce1fa22f563 (patch)
tree723fc74c64beff5f0a9d833e477ee2c3a66476eb /service
parent4e4d9ef7276d50f9e2741914ae0940d9a2165a65 (diff)
fix a couple of bugs recovering tag from a pickled json
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/tag.py2
-rw-r--r--service/pixelated/adapter/tag_service.py2
-rw-r--r--service/test/adapter/test_tag.py6
3 files changed, 7 insertions, 3 deletions
diff --git a/service/pixelated/adapter/tag.py b/service/pixelated/adapter/tag.py
index 2e965fdf..d75022f9 100644
--- a/service/pixelated/adapter/tag.py
+++ b/service/pixelated/adapter/tag.py
@@ -22,7 +22,7 @@ class Tag:
@classmethod
def from_dict(cls, tag_dict):
tag = Tag(tag_dict['name'], tag_dict['default'])
- tag.mails = tag_dict['mails']
+ tag.mails = set(tag_dict['mails'])
return tag
@classmethod
diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py
index dc13bc54..874a9a58 100644
--- a/service/pixelated/adapter/tag_service.py
+++ b/service/pixelated/adapter/tag_service.py
@@ -45,6 +45,8 @@ class TagService:
def notify_tags_updated(self, added_tags, removed_tags, mail_ident):
for removed_tag in removed_tags:
tag = self.tag_index.get(removed_tag)
+ if not tag:
+ continue
tag.decrement(mail_ident)
if tag.total == 0:
self.tag_index.remove(tag.name)
diff --git a/service/test/adapter/test_tag.py b/service/test/adapter/test_tag.py
index 85887d37..fc14ff49 100644
--- a/service/test/adapter/test_tag.py
+++ b/service/test/adapter/test_tag.py
@@ -27,14 +27,16 @@ class TestTag(unittest.TestCase):
'read': 1,
'starred': 1,
'replied': 1},
- 'mails': set([1, 2, 3])}
+ 'mails': [1, 2, 3]}
tag = Tag.from_dict(tag_dict)
self.assertEquals(tag_dict['name'], tag.name)
self.assertEquals(tag_dict['default'], tag.default)
self.assertEquals(tag_dict['counts']['total'], tag.total)
- self.assertEquals(tag_dict['mails'], tag.mails)
+ # Checks if mail ids are aways restored as set()
+ self.assertEquals(type(tag.mails), type(set()))
+ self.assertEquals(set(tag_dict['mails']), tag.mails)
def test_as_dict_puts_all_tag_attributes_in_the_returning_dict(self):
tag = Tag('some_tag', default=True)