示例#1
0
    def test_find_movie_success_by_own_url(self, browser_mock, base_init_mock, site_mock):
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = 'Flixster'
        inserter.failed_movies = []

        movie2 = dict()
        movie2['title'] = 'Fight Club'
        movie2['year'] = 1999

        result = inserter._find_movie(movie2)  # pylint: disable=protected-access

        self.assertTrue(result)
示例#2
0
    def test_find_movie_fail_at_search(self, browser_mock, base_init_mock, site_mock, search_mock, empty_result_mock):  # pylint: disable=too-many-arguments
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = 'Flixster'
        inserter.failed_movies = []
        search_mock.return_value = False
        empty_result_mock.return_value = True

        movie2 = dict()
        movie2['title'] = 'Not A Movie'
        movie2['year'] = 1999

        result = inserter._find_movie(movie2)  # pylint: disable=protected-access

        self.assertFalse(result)
示例#3
0
    def test_find_movie_success_directly_at_search(self, browser_mock,
                                                   base_init_mock, site_mock,
                                                   search_mock):
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = "Flixster"
        inserter.failed_movies = []
        search_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)
示例#4
0
    def test_find_movie_success_by_year(self, browser_mock, base_init_mock,
                                        site_mock):
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = "Flixster"
        inserter.failed_movies = []

        movie2 = dict()
        movie2["title"] = "Fight Club"
        movie2["year"] = 1999
        movie2["flixster"] = dict()
        movie2["flixster"][
            "url"] = "https://www.flixster.com/movie/fight-club/"

        result = inserter._find_movie(movie2)  # pylint: disable=protected-access

        self.assertTrue(result)
示例#5
0
    def test_find_movie_fail(self, browser_mock, base_init_mock, site_mock, tiles_mock, equality_mock):  # pylint: disable=too-many-arguments
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = 'Flixster'
        inserter.failed_movies = []
        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)
示例#6
0
    def test_find_movie_fail(self, browser_mock, base_init_mock, site_mock,
                             tiles_mock, equality_mock):  # pylint: disable=too-many-arguments
        site_mock.browser = browser_mock
        browser_mock.page_source = self.search_results
        inserter = FlixsterRatingsInserter(None)
        inserter.site = site_mock
        inserter.site.site_name = "Flixster"
        inserter.failed_movies = []
        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)
示例#7
0
    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):
        overview_page_mock.return_value = self.search_result_tile_list
        eq_check_mock.return_value = True
        site_mock.browser = browser_mock
        inserter = FlixsterRatingsInserter(None)
        inserter.args = False
        inserter.site = site_mock
        inserter.site.site_name = 'Flixster'
        inserter.failed_movies = []

        inserter.insert([self.movie], 'IMDB')

        self.assertTrue(base_init_mock.called)
        self.assertTrue(progress_print_mock.called)
示例#8
0
    def test_init(self, browser_mock, base_init_mock):
        FlixsterRatingsInserter(None)

        self.assertTrue(base_init_mock.called)