def test_create_watchlist_table(self): db = Sqlite() db.connect(database=TMP_DB) table_name = "watchlist" table_schema = remove_double_spaces("(show_id TEXT)") db.create_watchlist_table() count = table_count(db, table_name, table_schema) db.close() self.assertEqual(count, 1)
def test_watchlist(self): root, containers, media = create_test_library() db = Sqlite() db.connect(database=TMP_DB) db.create_containers_table() db.create_media_table() db.update_media(media) db.update_containers(containers) db.create_watchlist_table() container = containers[0] CONTAINER_ID = container.id() self.assertFalse(db.is_in_watchlists(CONTAINER_ID)) db.add_to_watchlist([CONTAINER_ID]) self.assertTrue(db.is_in_watchlists(CONTAINER_ID)) list = db.get_watchlist() self.assertEqual(len(list), 1) self.assertTrue(testutils.compare_containers(list[0], container)) db.remove_from_watchlist([CONTAINER_ID]) self.assertFalse(db.is_in_watchlists(CONTAINER_ID)) db.add_to_watchlist([containers[0].id(), containers[1].id()]) self.assertEqual(len(db.get_watchlist()), 2) db.remove_all_from_watchlist() self.assertEqual(len(db.get_watchlist()), 0) db.add_to_watchlist([CONTAINER_ID]) self.assertTrue(db.is_in_watchlists(CONTAINER_ID)) db.delete_containers([container]) self.assertIsNone(db.get_container(CONTAINER_ID)) list = db.get_watchlist() self.assertEqual(len(list), 0) self.assertFalse(db.is_in_watchlists(CONTAINER_ID)) db.close()