def test_sitemap_index(db_request): db_request.find_service = pretend.call_recorder( lambda *args, **kwargs: pretend.stub( enabled=False, csp_policy=pretend.stub(), merge=lambda _: None, ) ) project = ProjectFactory.create(name="foobar") users = [ UserFactory.create(username="******"), UserFactory.create(username="******"), ] # Have to pass this here, because passing date_joined=None to the create # function above makes the factory think it needs to generate a random # date. users[1].date_joined = None db_request.db.flush() assert sitemap.sitemap_index(db_request) == { "buckets": [ sitemap.Bucket("0", modified=project.created), sitemap.Bucket("1", modified=users[0].date_joined), sitemap.Bucket("5", modified=None), ], } assert db_request.response.content_type == "text/xml"
def test_sitemap_index(db_request): db_request.find_service = pretend.call_recorder( lambda *args, **kwargs: pretend.stub( enabled=False, csp_policy=pretend.stub(), merge=lambda _: None)) project = ProjectFactory.create(name="foobar", created=(datetime.utcnow() - timedelta(days=15))) users = [ UserFactory.create(username="******", date_joined=(datetime.utcnow() - timedelta(days=15))), UserFactory.create(username="******"), UserFactory.create(username="******", date_joined=(datetime.utcnow())), ] # Have to pass this here, because passing date_joined=None to the create # function above makes the factory think it needs to generate a random # date. users[1].date_joined = None db_request.db.flush() assert sitemap.sitemap_index(db_request) == { "buckets": [ sitemap.Bucket("0a", modified=project.created), sitemap.Bucket("1f", modified=users[0].date_joined), sitemap.Bucket("52", modified=None), ] } assert db_request.response.content_type == "text/xml"
def test_sitemap_index(db_request): project = ProjectFactory.create(name="foobar") users = [ UserFactory.create(username="******"), UserFactory.create(username="******"), ] # Have to pass this here, because passing date_joined=None to the create # function above makes the factory think it needs to generate a random # date. users[1].date_joined = None db_request.db.flush() assert sitemap.sitemap_index(db_request) == { "buckets": [ sitemap.Bucket("0", modified=project.created), sitemap.Bucket("1", modified=users[0].date_joined), sitemap.Bucket("5", modified=None), ], } assert db_request.response.content_type == "text/xml"