def test_ctx_factory(self): from clld.web.app import ctx_factory for model, route in [(Contribution, "contributions"), (ValueSet, "valuesets"), (Language, "languages")]: obj = model.first() self.set_request_properties(matchdict={"id": obj.id}, matched_route=Route(route)) ctx_factory(model, "index", self.env["request"]) ctx_factory(model, "rsc", self.env["request"]) self.set_request_properties(matchdict={"id": "xxx"}) self.assertRaises(HTTPNotFound, ctx_factory, Contribution, "rsc", self.env["request"])
def test_ctx_factory(self): from clld.web.app import ctx_factory for model, route in [ (Contribution, 'contributions'), (ValueSet, 'valuesets'), (Language, 'languages'), ]: obj = model.first() self.set_request_properties(matchdict={'id': obj.id}, matched_route=Route(route)) ctx_factory(model, 'index', self.env['request']) ctx_factory(model, 'rsc', self.env['request']) self.set_request_properties(matchdict={'id': 'xxx'}) self.assertRaises(HTTPNotFound, ctx_factory, Contribution, 'rsc', self.env['request'])
def test_ctx_factory(self): from clld.web.app import ctx_factory for model, route in [ (Contribution, 'contributions'), (ValueSet, 'valuesets'), (Language, 'languages'), ]: obj = model.first() self.set_request_properties( matchdict={'id': obj.id}, matched_route=Route(route)) ctx_factory(model, 'index', self.env['request']) ctx_factory(model, 'rsc', self.env['request']) self.set_request_properties(matchdict={'id': 'xxx'}) self.assertRaises( HTTPNotFound, ctx_factory, Contribution, 'rsc', self.env['request'])
def test_ctx_factory(request_factory): from clld.web.app import ctx_factory for model, route in [ (Contribution, 'contributions'), (ValueSet, 'valuesets'), (Language, 'languages'), ]: obj = model.first() with request_factory(matchdict={'id': obj.id}, matched_route=route) as req: ctx_factory(model, 'index', req) ctx_factory(model, 'rsc', req) with request_factory(matchdict={'id': 'xxx'}) as req: with pytest.raises(HTTPNotFound): ctx_factory(Contribution, 'rsc', req)