class TestDatabaseHierarchyMovies1(TestCase): def setUp(self): self.config = Config([]) self.db = DictDatabase() self.config.parse_dir(self.db, "movies1") def testFind(self): results = self.db.find("movie") assert len(results) == 38 h = results.hierarchy() self.assertEqual(len(h.children), 15) def testFindChildren1(self): results = self.db.find("movie", lambda s:s['title'] == "Moon") h = results.hierarchy() self.assertEqual(len(h.children), 1) self.assertEqual(len(h.children[0].children), 5) self.assertEqual(h.children[0].children[0]['title'], "Moon") self.assertEqual(h.children[0].children[0]['extraNumber'], 1) def testFindChildren2(self): results = self.db.find("movie", lambda s:s['title'] == "The Hunt for Red October") h = results.hierarchy() self.assertEqual(len(h.children), 1) self.assertEqual(len(h.children[0].children), 2) self.assertEqual(h.children[0].children[0]['title'], "The Hunt for Red October") self.assert_('extraNumber' not in h.children[0].children[0]) self.assertEqual(h.children[0].children[1]['title'], "The Hunt for Red October") self.assertEqual(h.children[0].children[1]['extraNumber'], 1)
class TestDatabaseGenre1(TestCase): def setUp(self): self.config = Config([]) self.db = DictDatabase() self.db.loadStateFromFile("movies1/dinoteeth.db") def testFind(self): results = self.db.find("movie") assert len(results) == 38 def testFindOne(self): results = self.db.find("movie", lambda s:s.has_metadata('genres', 'Comedy')) self.assertEquals(len(results), 6) results = self.db.find("movie", lambda s:s.has_metadata('genres', 'Adventure')) self.assertEquals(len(results), 8) results = self.db.find("movie", lambda s:s.has_metadata('genres', 'Biography')) self.assertEquals(len(results), 1) def testFindAllGenres(self): results = self.db.find("movie") genres = results.all_metadata('genres') self.assertEquals(len(genres), 13) def testFindAllDirectors(self): results = self.db.find("movie") people = results.all_metadata('directors') self.assertEquals(len(people), 12) results = self.db.find("movie", lambda s:s.has_metadata('directors', 'Edgar Wright')) self.assertEquals(len(results), 1) self.assertEquals(results[0]['title'], "Shaun of the Dead")
class TestDatabaseGeneral(TestCase): def setUp(self): self.config = Config([]) self.db = DictDatabase() def testFind(self): results = self.db.find("photos") assert len(results) == 0 h = results.hierarchy() self.assertEqual(len(h.children), 0)
class TestDatabaseHierarchySeries1(TestCase): def setUp(self): self.config = Config([]) self.db = DictDatabase() self.config.parse_dir(self.db, "series1") def testFind(self): results = self.db.find("episode") self.assertEqual(len(results), 32) h = results.hierarchy() print h self.assertEqual(len(h.children), 5) def testFindChildren1(self): results = self.db.find("episode", lambda s:s['series'] == "The Big Bang Theory") self.assertEqual(len(results), 22) h = results.hierarchy() print h self.assertEqual(len(h.children), 1) # Look at the series series = h.children[0] self.assertEqual(series['series'], "The Big Bang Theory") # Look at the second season season2 = series.children[1] self.assertEqual(season2['series'], "The Big Bang Theory") c = season2.children self.assertEqual(len(c), 6) self.assertEqual(c[0]['series'], "The Big Bang Theory") self.assertEqual(c[0]['season'], 2) self.assertEqual(c[0]['episodeNumber'], 1) self.assertEqual(c[1]['series'], "The Big Bang Theory") self.assertEqual(c[1]['season'], 2) self.assertEqual(c[1]['episodeNumber'], 2) self.assertEqual(c[5]['series'], "The Big Bang Theory") self.assertEqual(c[5]['season'], 2) self.assertEqual(c[5]['extraNumber'], 3)
class TestMenuMovies1(TestCase): def setUp(self): self.config = Config([]) self.db = DictDatabase() self.config.parse_dir(self.db, "movies1") def testMenu1(self): results = self.db.find("movie") assert len(results) == 38 h = results.hierarchy() h.pprint() self.assertEqual(len(h.children), 15) menu = self.root menu.add_hierarchy(h) self.assertEqual(len(menu.children), 15) self.assertEqual(menu.children[9].title, "The Hunt for Red October") self.assertEqual(menu.children[9].children[0].title, "The Hunt for Red October") self.assertEqual(menu.children[9].children[1].title, " Play")