예제 #1
0
    def test_works_query(self):
        # Prep an empty result.
        mock_api = self.generate_mock_api()

        # With an empty recommendation result, the lane is empty.
        lane = RecommendationLane(self._db, self.lp, '', novelist_api=mock_api)
        eq_(None, lane.works())
        eq_(None, lane.materialized_works())

        # Resulting recommendations are returned when available, though.
        result = self._work(with_license_pool=True)
        lane.recommendations = [result.license_pools[0].identifier]
        SessionManager.refresh_materialized_views(self._db)
        self.assert_works_queries(lane, [result])
예제 #2
0
    def test_works_query(self):
        # Prep an empty result.
        mock_api = self.generate_mock_api()

        # With an empty recommendation result, the lane is empty.
        lane = RecommendationLane(self._default_library, self.work, '', novelist_api=mock_api)
        eq_(None, lane.works(self._db))

        # Resulting recommendations are returned when available, though.
        # TODO: Setting a data source name is necessary because Gutenberg
        # books get filtered out when children or ya is one of the lane's
        # audiences.
        result = self._work(with_license_pool=True, data_source_name=DataSource.OVERDRIVE)
        lane.recommendations = [result.license_pools[0].identifier]
        SessionManager.refresh_materialized_views(self._db)
        self.assert_works_queries(lane, [result])
예제 #3
0
    def test_works_query(self):
        # Prep an empty result.
        mock_api = self.generate_mock_api()

        # With an empty recommendation result, the lane is empty.
        lane = RecommendationLane(self._default_library, self.work, '', novelist_api=mock_api)
        eq_(None, lane.works(self._db))

        # Resulting recommendations are returned when available, though.
        # TODO: Setting a data source name is necessary because Gutenberg
        # books get filtered out when children or ya is one of the lane's
        # audiences.
        result = self._work(with_license_pool=True, data_source_name=DataSource.OVERDRIVE)
        lane.recommendations = [result.license_pools[0].identifier]
        SessionManager.refresh_materialized_views(self._db)
        self.assert_works_queries(lane, [result])