Esempio n. 1
0
    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"])
Esempio n. 2
0
    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'])
Esempio n. 3
0
    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'])
Esempio n. 4
0
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)
Esempio n. 5
0
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)