Beispiel #1
0
 def test_save_calendar_id_already_exists(self):
     cal = Calendar(CAL_TITLE, CAL_URL, self.__last_update, CAL_TZ)
     mgr = TestCache(db=TEST_DB_FILE)
     mgr.save(cal)
     cal = Calendar("", CAL_URL, "", CAL_TZ)
     self.assertRaises(Exception, mgr.save, cal)
     mgr.close()
Beispiel #2
0
    def test_save(self):
        cal = Calendar(CAL_TITLE, CAL_URL, self.__last_update, CAL_TZ)
        mgr = TestCache(db=TEST_DB_FILE)
        mgr.save(cal)

        loaded_cal = mgr.load(cal.url)
        self.assertEqual(CAL_TITLE, loaded_cal.title)
        self.assertEqual(CAL_URL, loaded_cal.url)
        self.assertEqual(self.__last_update, loaded_cal.last_update)
Beispiel #3
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()))
Beispiel #4
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()))
Beispiel #5
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()))
Beispiel #6
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()))
Beispiel #7
0
 def test_delete_readd_without_close(self):
     cal = Calendar(CAL_TITLE, CAL_URL, self.__last_update, CAL_TZ)
     mgr = TestCache(db=TEST_DB_FILE)
     mgr.save(cal)
     mgr.delete(cal.url)
     mgr.save(cal)