Exemple #1
0
 def test_removing_game(self):
     """Test that a game is properly removed from the database"""
     responses.add(responses.GET, "http://thegamesdb.net/api/GetGamesList.php",
                   body=base64.b64decode(resps["FIFA 14"]["data"]),
                   status=200, content_type="text/xml")
     game = Item("game", "FIFA 14")
     with mock.patch("__builtin__.raw_input", return_value="16"):
         game.find(False)
     game.set_state("have")
     assert(Item.select().where(Item.item_ID == "18817").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("game", "18817", False)
     assert(not Item.select().where(Item.item_ID == "18817").first())
Exemple #2
0
 def test_removing_item_of_wrong_type(self):
     """Test specifying the wrong type when removing doesn't remove the item"""
     responses.add(responses.GET, "http://omdbapi.com/",
                   body=json.dumps(resps["The Godfather"]),
                   status=200, content_type="application/json")
     movie = Item("movie", "The Godfather")
     with mock.patch("__builtin__.raw_input", return_value="y"):
         movie.find(False)
     movie.set_state("have")
     assert(Item.select().where(Item.item_ID == u"tt0068646").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("book", "tt0068646", False)
     assert(Item.select().where(Item.item_ID == u"tt0068646").first())
Exemple #3
0
 def test_removing_book(self):
     """Test that a book is properly removed from the database"""
     responses.add(responses.GET, "https://www.googleapis.com/books/v1/volumes",
                   body=json.dumps(resps["A Game of Thrones"]),
                   status=200, content_type="application/json")
     book = Item("book", "A Game of Thrones")
     with mock.patch("__builtin__.raw_input", return_value="3"):
         book.find(False)
     book.set_state("have")
     assert(Item.select().where(Item.item_ID == u"btpIkZ6X6egC").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("book", "btpIkZ6X6egC", False)
     assert(not Item.select().where(Item.item_ID == u"btpIkZ6X6egC").first())
Exemple #4
0
 def test_removing_tv_show(self):
     """Test that a TV show is properly removed from the database"""
     responses.add(responses.GET, "http://omdbapi.com/",
                   body=json.dumps(resps["The Sopranos"]),
                   status=200, content_type="application/json")
     show = Item("TV show", "The Sopranos")
     with mock.patch("__builtin__.raw_input", return_value="y"):
         show.find(False)
     show.set_state("have")
     assert(Item.select().where(Item.item_ID == u"tt0141842").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("TV show", "tt0141842", False)
     assert(not Item.select().where(Item.item_ID == u"tt0141842").first())
Exemple #5
0
 def test_removing_movie(self):
     """Test that a movie is properly removed from the database"""
     responses.add(responses.GET, "http://omdbapi.com/",
                   body=json.dumps(resps["The Godfather"]),
                   status=200, content_type="application/json")
     movie = Item("movie", "The Godfather")
     with mock.patch("__builtin__.raw_input", return_value="y"):
         movie.find(False)
     movie.set_state("have")
     assert(Item.select().where(Item.item_ID == u"tt0068646").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("movie", "tt0068646", False)
     assert(not Item.select().where(Item.item_ID == u"tt0068646").first())
Exemple #6
0
 def test_removing_item_with_unicode_title(self):
     """Test removing an item with unicode in the title from the database"""
     responses.add(responses.GET, "http://omdbapi.com/",
                   body=json.dumps(resps[u"WALL·E"]),
                   status=200, content_type="application/json")
     movie = Item("movie", u"WALL·E")
     with mock.patch("__builtin__.raw_input", return_value="y"):
         movie.find(False)
     movie.set_state("have")
     assert(Item.select().where(Item.item_ID == u"tt0910970").first())
     with mock.patch("__builtin__.raw_input", return_value="y"):
         remove_item("movie", "tt0910970", False)
     assert(not Item.select().where(Item.item_ID == u"tt0910970").first())
Exemple #7
0
 def test_removing_non_existent_item(self):
     """Test removing an item that doesn't exist from the database"""
     assert(not Item.select().where(Item.item_ID == u"tt0071562").first())
     remove_item("movie", "tt0071562", False)