Exemplo n.º 1
0
 def test_compare_by_runtime(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertEqual(
         [("The Godfather", "2h55min")],
         self.db_api.select_one(query.compare("runtime"),
                                data=("The Godfather", "Gods")),
     )
Exemplo n.º 2
0
 def test_compare_by_awards_won(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertEqual(
         [("The Godfather", "24")],
         self.db_api.select_one(query.compare("awards"),
                                data=("The Godfather", "Gods")),
     )
Exemplo n.º 3
0
 def test_compare_by_boxoffice_earnings(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertEqual(
         [("Memento", "$23,844,220")],
         self.db_api.select_one(query.compare("boxoffice"),
                                data=("Memento", "In Bruges")),
     )
Exemplo n.º 4
0
 def test_compare_by_imdb_rating(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertEqual(
         [("The Godfather", "9.2")],
         self.db_api.select_one(query.compare("imdb"),
                                data=("The Godfather", "Gods")),
     )
Exemplo n.º 5
0
 def test_compare_when_one_na(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertEqual(
         [("In Bruges", "$7,550,836")],
         self.db_api.select_one(
             query.compare("boxoffice"),
             data=("In Bruges", "Gods"),
         ),
     )
Exemplo n.º 6
0
 def test_compare_movie_not_in_db(self):
     self.db_api.insert_many(query.update(), self.update_data)
     self.assertRaises(
         ValueError,
         lambda: self.db_api.select_one(
             query.compare("imdb"),
             data=("The Dogfather", "The Godfather,"),
             check=True,
         ),
     )
Exemplo n.º 7
0
 def compare(self, category, movie1, movie2):
     """Compare two movies by a category."""
     try:
         data = self.db_api.select_one(query.compare(category),
                                       data=(movie1, movie2),
                                       check=True)
         if not data[0][1] or data[0][1] == "N/A":
             raise ValueError(
                 "Can't compare movies in that category, due to lack of data."
             )
         return self.printer.display(data, columns=[category])
     except ValueError as err:
         return ", ".join(err.args)