File: iconcachetest.py

package info (click to toggle)
miro 3.0.3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 36,056 kB
  • ctags: 9,438
  • sloc: python: 52,860; cpp: 832; ansic: 692; xml: 432; sh: 403; makefile: 62
file content (55 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from miro import database

from miro import app
from miro import iconcache
from miro import item
from miro import feed
from miro import guide

from miro.test.framework import EventLoopTest

class IconCacheTest(EventLoopTest):
    def setUp(self):
        EventLoopTest.setUp(self)
        self.feed = feed.Feed(u'http://example.com/')
        self.item = item.Item(item.FeedParserValues({}), feed_id=self.feed.id)
        self.guide = guide.ChannelGuide(u'http://example.com/guide/')

    def test_ddbobject_removed(self):
        """Test that we remove our IconCache DDBObject when it's
        container is removed.
        """
        feed_icon_cache = self.feed.icon_cache
        item_icon_cache = self.item.icon_cache
        guide_icon_cache = self.guide.icon_cache
        self.item.remove()
        self.feed.remove()
        self.guide.remove()

        self.assert_(not feed_icon_cache.id_exists())
        self.assert_(not item_icon_cache.id_exists())
        self.assert_(not guide_icon_cache.id_exists())

    def test_remove_before_icon_cache_referenced(self):
        # Items create the icon_cache attribute lazily when restored
        # from db.  Make sure that removing an item before it's
        # created is okay.

        # trick LiveStorage into restoring our feed, item and guide
        self.feed = self.reload_object(self.feed)
        self.item = self.reload_object(self.item)
        self.guide = self.reload_object(self.guide)

        feed_icon_cache_id = self.feed.icon_cache_id
        item_icon_cache_id = self.item.icon_cache_id
        guide_icon_cache_id = self.guide.icon_cache_id
        self.item.remove()
        self.feed.remove()
        self.guide.remove()

        self.assertRaises(database.ObjectNotFoundError,
                iconcache.IconCache.get_by_id, feed_icon_cache_id)
        self.assertRaises(database.ObjectNotFoundError,
                iconcache.IconCache.get_by_id, item_icon_cache_id)
        self.assertRaises(database.ObjectNotFoundError,
                iconcache.IconCache.get_by_id, guide_icon_cache_id)