示例#1
0
    def test_empty_cache(self):
        cal = Calendar(CAL_TITLE, CAL_URL, self.__last_update, CAL_TZ)
        mgr = TestCache(db=TEST_DB_FILE)
        mgr.save(cal)
        self.assertEqual(1, len(mgr.load_all()))

        mgr.empty()
        self.assertEqual(0, len(mgr.load_all()))
示例#2
0
    def test_initial_update(self):
        test_feed_source = utils.TestFeedSource()
        cal = self.__create_test_calendar_data()
        test_feed_source.calendars[CAL_URL] = cal
        urls = [CAL_URL]
        test_config = TestWujaConfiguration(urls, feed_source=test_feed_source)

        cache = TestCache(test_config.db_file)
        self.assertEqual(0, len(cache.load_all()))
        self.notifier = Notifier(test_config, cache)

        # Check that our objects were created:
        self.assertEqual(1, len(cache.load_all()))
示例#3
0
    def test_feed_updated_entries_removed(self):
        test_feed_source = utils.TestFeedSource()
        cal = self.__create_test_calendar_data()
        test_feed_source.calendars[CAL_URL] = cal
        urls = [CAL_URL]
        test_config = TestWujaConfiguration(urls, feed_source=test_feed_source)

        cache = TestCache(test_config.db_file)
        self.assertEqual(0, len(cache.load_all()))
        self.notifier = Notifier(test_config, cache)

        # Check that our objects were created:
        self.assertEqual(1, len(cache.load_all()))

        # Remove an entry:
        cal.entries.pop()
        cal.last_update = "new time" # change last update time
        self.notifier.update()
        self.assertEqual(1, len(cache.load_all()))
示例#4
0
    def test_feed_updated_entries_added(self):
        test_feed_source = utils.TestFeedSource()
        cal = self.__create_test_calendar_data()
        test_feed_source.calendars[CAL_URL] = cal
        urls = [CAL_URL]
        test_config = TestWujaConfiguration(urls, feed_source=test_feed_source)

        cache = TestCache(test_config.db_file)
        self.assertEqual(0, len(cache.load_all()))
        self.notifier = Notifier(test_config, cache)

        # Check that our objects were created:
        self.assertEqual(1, len(cache.load_all()))

        # Add a new entry:
        cal.entries.append(SingleOccurrenceEntry("singleid",
            "Another Entry", "desc", REMIND, datetime.now(TZ), datetime.now(TZ),
            3600, "Another location.", cal))
        cal.last_update = "new time" # change last update time
        self.notifier.update()
        self.assertEqual(1, len(cache.load_all()))