def test_find_movie_fail( self, browser_mock, base_init_mock, site_mock, compare_mock, tiles_mock, equality_mock, ): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.search_results inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = "Listal" inserter.failed_movies = [] compare_mock.return_value = False tiles_mock.return_value = self.search_result_tile_list equality_mock.return_value = False movie2 = dict() movie2["title"] = "The Matrix" movie2["year"] = 1995 movie2["imdb"] = dict() movie2["imdb"]["id"] = "tt0137523" movie2["imdb"]["url"] = "https://www.imdb.com/title/tt0137523" movie2["imdb"]["my_rating"] = 9 result = inserter._find_movie(movie2) # pylint: disable=protected-access self.assertFalse(result)
def test_external_link_compare_imdb_fail(self, browser_mock, base_init_mock, site_mock): site_mock.browser = browser_mock inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] result = inserter._compare_external_links(self.movie_details_page, self.movie, 'imdb.com', 'imdb') # pylint: disable=protected-access self.assertTrue(result)
def test_find_movie_success_by_imdb(self, browser_mock, base_init_mock, site_mock, compare_mock): site_mock.browser = browser_mock browser_mock.page_source = self.search_results inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] compare_mock.return_value = True result = inserter._find_movie(self.movie) # pylint: disable=protected-access self.assertTrue(result)
def test_compare_fail_by_year(self, browser_mock, base_init_mock, site_mock): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.movie_details_page inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] movie2 = dict() movie2['title'] = 'The Matrix' movie2['year'] = 1995 search_result = BeautifulSoup(self.search_result_tile_list[0], 'html.parser') result = inserter._is_requested_movie(movie2, search_result) # pylint: disable=protected-access self.assertFalse(result)
def test_find_movie_success_by_year(self, browser_mock, base_init_mock, site_mock, compare_mock, equality_mock): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.search_results inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] compare_mock.return_value = True equality_mock.return_value = True movie2 = dict() movie2['title'] = 'Fight Club' movie2['year'] = 1999 result = inserter._find_movie(movie2) # pylint: disable=protected-access self.assertTrue(result)
def test_external_link_compare_imdb_success(self, browser_mock, base_init_mock, site_mock): site_mock.browser = browser_mock inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] movie2 = dict() movie2['title'] = 'The Simpsons' movie2['year'] = 2007 movie2['imdb'] = dict() movie2['imdb']['id'] = 'tt0462538' movie2['imdb']['url'] = 'http://www.imdb.com/title/tt0462538' movie2['imdb']['my_rating'] = 10 result = inserter._compare_external_links(self.movie_details_page, movie2, 'imdb.com', 'imdb') # pylint: disable=protected-access self.assertFalse(result)
def test_compare_success_by_year( self, browser_mock, base_init_mock, site_mock ): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.movie_details_page inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = "Listal" inserter.failed_movies = [] movie2 = dict() movie2["title"] = "Fight Club" movie2["year"] = 1999 search_result = BeautifulSoup(self.search_result_tile_list[0], "html.parser") result = inserter._is_requested_movie( movie2, search_result ) # pylint: disable=protected-access self.assertTrue(result)
def test_compare_success_by_imdb(self, browser_mock, base_init_mock, site_mock): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.movie_details_page inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] movie2 = dict() movie2['title'] = 'Fight Club' movie2['year'] = 1998 movie2['imdb'] = dict() movie2['imdb']['id'] = 'tt0137523' movie2['imdb']['url'] = 'http://www.imdb.com/title/tt0137523' movie2['imdb']['my_rating'] = 9 search_result = BeautifulSoup(self.search_result_tile_list[0], 'html.parser') result = inserter._is_requested_movie(movie2, search_result) # pylint: disable=protected-access self.assertTrue(result)
def test_target_movie_detail_page_has_no_year( self, browser_mock, base_init_mock, site_mock ): # pylint: disable=too-many-arguments with open( os.path.join( TESTDATA_PATH, "listal", "movie_details_page_without_release_year.html" ), encoding="UTF-8", ) as movie_details_page_without_release_year: movie_details_page_without_release_year = ( movie_details_page_without_release_year.read() ) site_mock.browser = browser_mock browser_mock.page_source = movie_details_page_without_release_year inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = "Listal" inserter.failed_movies = [] inserter.args = None movie2 = dict() movie2["title"] = "Fight Club" movie2["year"] = 1999 search_result = BeautifulSoup(self.search_result_tile_list[0], "html.parser") result = inserter._is_requested_movie( movie2, search_result ) # pylint: disable=protected-access self.assertFalse(result)
def test_external_link_compare_imdb_success( self, browser_mock, base_init_mock, site_mock ): site_mock.browser = browser_mock inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = "Listal" inserter.failed_movies = [] movie2 = dict() movie2["title"] = "The Simpsons" movie2["year"] = 2007 movie2["imdb"] = dict() movie2["imdb"]["id"] = "tt0462538" movie2["imdb"]["url"] = "https://www.imdb.com/title/tt0462538" movie2["imdb"]["my_rating"] = 10 result = inserter._compare_external_links( self.movie_details_page, movie2, "imdb.com", "imdb" ) # pylint: disable=protected-access self.assertFalse(result)
def test_find_movie_fail(self, browser_mock, base_init_mock, site_mock, compare_mock, tiles_mock, equality_mock): # pylint: disable=too-many-arguments site_mock.browser = browser_mock browser_mock.page_source = self.search_results inserter = ListalRatingsInserter(None) inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] compare_mock.return_value = False tiles_mock.return_value = self.search_result_tile_list equality_mock.return_value = False movie2 = dict() movie2['title'] = 'The Matrix' movie2['year'] = 1995 movie2['imdb'] = dict() movie2['imdb']['id'] = 'tt0137523' movie2['imdb']['url'] = 'http://www.imdb.com/title/tt0137523' movie2['imdb']['my_rating'] = 9 result = inserter._find_movie(movie2) # pylint: disable=protected-access self.assertFalse(result)
def test_insert(self, browser_mock, base_init_mock, site_mock, overview_page_mock, # pylint: disable=too-many-arguments eq_check_mock, progress_print_mock, post_rating_mock): overview_page_mock.return_value = self.search_result_tile_list eq_check_mock.return_value = True site_mock.browser = browser_mock inserter = ListalRatingsInserter(None) inserter.args = False inserter.site = site_mock inserter.site.site_name = 'Listal' inserter.failed_movies = [] inserter.insert([self.movie], 'IMDB') self.assertTrue(base_init_mock.called) self.assertTrue(progress_print_mock.called)
def test_init(self, browser_mock, base_init_mock): ListalRatingsInserter(None) self.assertTrue(base_init_mock.called)