def test_parser_dislikes(self, site_mock, base_init_mock, browser_mock, progress_print_mock): # pylint: disable=too-many-arguments browser_mock.page_source = self.my_ratings_dislike site_mock.PARSE_LIKE_TRANSLATION = 8 site_mock.PARSE_DISLIKE_TRANSLATION = 3 parser = ICheckMoviesRatingsParser(None) parser.args = False parser.movies = [] parser.site = site_mock parser.site.site_name = 'ICheckMovies' parser.site.browser = browser_mock parser.args = None parser._parse_movies_category('mock-url', 'dislike') # pylint: disable=protected-access self.assertEqual(25, len(parser.movies)) self.assertEqual(dict, type(parser.movies[0])) self.assertEqual('Daniel der Zauberer', parser.movies[0]['title']) self.assertEqual('119234', parser.movies[0]['icheckmovies']['id']) self.assertEqual( 'https://www.icheckmovies.com/movies/daniel+der+zauberer/', parser.movies[0]['icheckmovies']['url']) self.assertEqual(2004, parser.movies[0]['year']) self.assertEqual('tt0421051', parser.movies[0]['imdb']['id']) self.assertEqual('http://www.imdb.com/title/tt0421051', parser.movies[0]['imdb']['url']) self.assertEqual(3, parser.movies[0]['icheckmovies']['my_rating'])
def test_parser_likes(self, site_mock, base_init_mock, browser_mock, progress_print_mock): # pylint: disable=too-many-arguments browser_mock.page_source = self.my_ratings_like site_mock.PARSE_LIKE_TRANSLATION = 8 site_mock.PARSE_DISLIKE_TRANSLATION = 3 parser = ICheckMoviesRatingsParser(None) parser.args = False parser.movies = [] parser.site = site_mock parser.site.site_name = 'ICheckMovies' parser.site.browser = browser_mock parser.args = None parser._parse_movies_category('mock-url', 'like') # pylint: disable=protected-access self.assertEqual(240, len(parser.movies)) self.assertEqual(dict, type(parser.movies[0])) self.assertEqual('Fight Club', parser.movies[0]['title']) self.assertEqual('21', parser.movies[0]['icheckmovies']['id']) self.assertEqual('https://www.icheckmovies.com/movies/fight+club/', parser.movies[0]['icheckmovies']['url']) self.assertEqual(1999, parser.movies[0]['year']) self.assertEqual('tt0137523', parser.movies[0]['imdb']['id']) self.assertEqual('http://www.imdb.com/title/tt0137523', parser.movies[0]['imdb']['url']) self.assertEqual(8, parser.movies[0]['icheckmovies']['my_rating'])
def test_parser_dislikes(self, site_mock, base_init_mock, browser_mock, progress_print_mock): # pylint: disable=too-many-arguments browser_mock.page_source = self.my_ratings_dislike site_mock.PARSE_LIKE_TRANSLATION = 8 site_mock.PARSE_DISLIKE_TRANSLATION = 3 parser = ICheckMoviesRatingsParser(None) parser.args = False parser.movies = [] parser.site = site_mock parser.site.site_name = "ICheckMovies" parser.site.browser = browser_mock parser.args = None parser._parse_movies_category("mock-url", "dislike") # pylint: disable=protected-access self.assertEqual(25, len(parser.movies)) self.assertEqual(dict, type(parser.movies[0])) self.assertEqual("Daniel der Zauberer", parser.movies[0]["title"]) self.assertEqual("119234", parser.movies[0]["icheckmovies"]["id"]) self.assertEqual( "https://www.icheckmovies.com/movies/daniel+der+zauberer/", parser.movies[0]["icheckmovies"]["url"], ) self.assertEqual(2004, parser.movies[0]["year"]) self.assertEqual("tt0421051", parser.movies[0]["imdb"]["id"]) self.assertEqual("https://www.imdb.com/title/tt0421051", parser.movies[0]["imdb"]["url"]) self.assertEqual(3, parser.movies[0]["icheckmovies"]["my_rating"])
def test_parser_likes(self, site_mock, base_init_mock, browser_mock, progress_print_mock): # pylint: disable=too-many-arguments browser_mock.page_source = self.my_ratings_like site_mock.PARSE_LIKE_TRANSLATION = 8 site_mock.PARSE_DISLIKE_TRANSLATION = 3 parser = ICheckMoviesRatingsParser(None) parser.args = False parser.movies = [] parser.site = site_mock parser.site.site_name = "ICheckMovies" parser.site.browser = browser_mock parser.args = None parser._parse_movies_category("mock-url", "like") # pylint: disable=protected-access self.assertEqual(240, len(parser.movies)) self.assertEqual(dict, type(parser.movies[0])) self.assertEqual("Fight Club", parser.movies[0]["title"]) self.assertEqual("21", parser.movies[0]["icheckmovies"]["id"]) self.assertEqual( "https://www.icheckmovies.com/movies/fight+club/", parser.movies[0]["icheckmovies"]["url"], ) self.assertEqual(1999, parser.movies[0]["year"]) self.assertEqual("tt0137523", parser.movies[0]["imdb"]["id"]) self.assertEqual("https://www.imdb.com/title/tt0137523", parser.movies[0]["imdb"]["url"]) self.assertEqual(8, parser.movies[0]["icheckmovies"]["my_rating"])
def test_parser(self, site_mock, base_init_mock, browser_mock, parse_category_mock, progress_print_mock): # pylint: disable=too-many-arguments browser_mock.page_source = self.my_ratings_like parser = ICheckMoviesRatingsParser(None) parser.args = False parser.movies = [] parser.site = site_mock parser.site.site_name = 'ICheckMovies' parser.site.browser = browser_mock parser.args = None parser.parse() self.assertEqual(2, parse_category_mock.call_count)
def test_init(self, browser_mock, base_init_mock): ICheckMoviesRatingsParser(None) self.assertTrue(base_init_mock.called)