Exemplo n.º 1
0
    def test_route_with_id_placeholder(self):
        def route_url(route_name, **kwargs):
            return '/{}/{}'.format(route_name, kwargs['id'])

        templater = api_config.AngularRouteTemplater(route_url, params=['id'])

        assert templater.route_template('foo') == '/foo/:id'
Exemplo n.º 2
0
    def test_static_route(self):
        def route_url(route_name, **kwargs):
            return '/' + route_name

        templater = api_config.AngularRouteTemplater(route_url, params=[])

        assert templater.route_template('foo') == '/foo'
Exemplo n.º 3
0
    def test_route_with_id_placeholder(self):
        def route_url(route_name, **kwargs):
            return "/{}/{}".format(route_name, kwargs["id"])

        templater = api_config.AngularRouteTemplater(route_url, params=["id"])

        assert templater.route_template("foo") == "/foo/:id"
Exemplo n.º 4
0
    def test_parameter_substrings(self):
        def route_url(_, **kwargs):
            return '/api/{}/things/{}'.format(kwargs['id'], kwargs['thing_id'])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=['id', 'thing_id'])

        assert templater.route_template('foo') == '/api/:id/things/:thing_id'
Exemplo n.º 5
0
    def test_multiple_parameters(self):
        def route_url(_, **kwargs):
            return '/{}/{}'.format(kwargs['foo'], kwargs['bar'])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=['foo', 'bar'])

        assert templater.route_template('foo') == '/:foo/:bar'
Exemplo n.º 6
0
    def test_custom_parameter(self):
        def route_url(_, **kwargs):
            return '/things/{}'.format(kwargs['thing_id'])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=['thing_id'])

        assert templater.route_template('foo') == '/things/:thing_id'
Exemplo n.º 7
0
    def test_parameter_substrings(self):
        def route_url(_, **kwargs):
            return "/api/{}/things/{}".format(kwargs["id"], kwargs["thing_id"])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=["id", "thing_id"])

        assert templater.route_template("foo") == "/api/:id/things/:thing_id"
Exemplo n.º 8
0
    def test_multiple_parameters(self):
        def route_url(_, **kwargs):
            return "/{}/{}".format(kwargs["foo"], kwargs["bar"])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=["foo", "bar"])

        assert templater.route_template("foo") == "/:foo/:bar"
Exemplo n.º 9
0
    def test_custom_parameter(self):
        def route_url(_, **kwargs):
            return "/things/{}".format(kwargs["thing_id"])

        templater = api_config.AngularRouteTemplater(route_url,
                                                     params=["thing_id"])

        assert templater.route_template("foo") == "/things/:thing_id"