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 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")
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)
def setUp(self): self.config = Config([]) self.db = DictDatabase() self.config.parse_dir(self.db, "series1")
def currentPath(): '''Returns the path in which the calling file is located.''' return os.path.dirname(os.path.join(os.getcwd(), sys._getframe(1).f_globals['__file__'])) def addImportPath(path): '''Function that adds the specified path to the import path. The path can be absolute or relative to the calling file.''' importPath = os.path.abspath(os.path.join(currentPath(), path)) sys.path = [ importPath ] + sys.path from dinoteeth.metadata import MovieMetadataDatabase, UnifiedMetadataDatabase from dinoteeth.config import Config from dinoteeth.utils import ArtworkLoader if __name__ == "__main__": parser = Config.get_arg_parser() parser.add_option("--batch-metadata-database", action="store", dest="bdb", default="dinoteeth.bdb") parser.add_option("-r", "--regenerate", action="store_true", dest="regenerate", default=False) parser.add_option("--posters", action="store_true", dest="posters", default=False) parser.add_option("-f", "--fetch", action="store_true", dest="fetch", default=False) c = Config(sys.argv, parser) db = c.db umdb = c.umdb options = c.options if options.regenerate: bdb = MovieMetadataDatabase() bdb.loadStateFromFile(options.bdb) results = db.find("movie") for i, movie in enumerate(results):