def items_mock(self): return [ AddonSitemap.item_tuple(datetime(2020, 10, 2, 0, 0, 0), 'delicious-pierogi', 'detail'), AddonSitemap.item_tuple(datetime(2020, 10, 1, 0, 0, 0), 'swanky-curry', 'detail'), AddonSitemap.item_tuple(datetime(2020, 9, 30, 0, 0, 0), 'spicy-pierogi', 'detail'), ]
def items_mock(self): return [ AddonSitemap.item_tuple( datetime(2020, 10, 2, 0, 0, 0), 'delicious-barbeque', 'detail' ), AddonSitemap.item_tuple( datetime(2020, 10, 1, 0, 0, 0), 'spicy-sandwich', 'detail' ), AddonSitemap.item_tuple( datetime(2020, 9, 30, 0, 0, 0), 'delicious-chocolate', 'detail' ), AddonSitemap.item_tuple( datetime(2020, 10, 2, 0, 0, 0), 'delicious-barbeque', 'versions' ), AddonSitemap.item_tuple( datetime(2020, 10, 1, 0, 0, 0), 'spicy-sandwich', 'versions' ), AddonSitemap.item_tuple( datetime(2020, 9, 30, 0, 0, 0), 'delicious-chocolate', 'versions' ), AddonSitemap.item_tuple( datetime(2020, 10, 2, 0, 0, 0), 'delicious-barbeque', 'ratings.list' ), AddonSitemap.item_tuple( datetime(2020, 10, 1, 0, 0, 0), 'spicy-sandwich', 'ratings.list' ), AddonSitemap.item_tuple( datetime(2020, 9, 30, 0, 0, 0), 'delicious-chocolate', 'ratings.list' ), ]
def items_mock(self): return [ AddonSitemap.item_tuple( datetime(2020, 10, 2, 0, 0, 0), reverse('addons.detail', args=['delicious-barbeque']), ), AddonSitemap.item_tuple( datetime(2020, 10, 1, 0, 0, 0), reverse('addons.detail', args=['spicy-sandwich']), ), AddonSitemap.item_tuple( datetime(2020, 9, 30, 0, 0, 0), reverse('addons.detail', args=['delicious-chocolate']), ), AddonSitemap.item_tuple( datetime(2020, 10, 2, 0, 0, 0), reverse('addons.ratings.list', args=['delicious-barbeque']), ), AddonSitemap.item_tuple( datetime(2020, 10, 1, 0, 0, 0), reverse('addons.ratings.list', args=['spicy-sandwich']), ), AddonSitemap.item_tuple( datetime(2020, 9, 30, 0, 0, 0), reverse('addons.ratings.list', args=['delicious-chocolate']), ), ]
def test_rating_pagination(self): # add some ratings to test the rating page pagination rating_factory(self.addon_c) rating_factory(self.addon_c) rating_factory(self.addon_c) rating_factory(self.addon_a) rating_factory(self.addon_a) # only 2 for addon_a patched_drf_setting = dict(settings.REST_FRAMEWORK) patched_drf_setting['PAGE_SIZE'] = 2 sitemap = AddonSitemap() with override_settings(REST_FRAMEWORK=patched_drf_setting): items_with_ratings = list(sitemap.items()) # only one extra url, for a second ratings page, because PAGE_SIZE = 2 extra_rating = AddonSitemap.item_tuple( self.addon_c.last_updated, self.addon_c.slug, 'ratings.list', 2 ) assert extra_rating in items_with_ratings assert set(items_with_ratings) - set(self.expected) == {extra_rating} item = items_with_ratings[-3] assert sitemap.location(item).endswith('/reviews/?page=2') assert sitemap.lastmod(item) == item.last_updated