예제 #1
0
    def test_it_formats_link_objects_as_dicts(self, templater):
        link = _service_link(name="flat")

        formatted = links.format_nested_links([link], "v1", templater)

        assert "flat" in formatted
        assert formatted["flat"] == {
            "method": link.primary_method(),
            "url": templater.route_template(link.route_name),
            "desc": link.description,
        }
예제 #2
0
파일: index.py 프로젝트: y3g0r/h
def index_v2(context, request):
    """Return the API descriptor document.

    Clients may use this to discover endpoints for the API.
    """

    api_links = request.registry.api_links["v2"]

    templater = AngularRouteTemplater(
        request.route_url,
        params=["id", "pubid", "user", "userid", "username"])

    return {"links": link_helpers.format_nested_links(api_links, templater)}
예제 #3
0
파일: index.py 프로젝트: hypothesis/h
def index_v2(context, request):
    """Return the API descriptor document.

    Clients may use this to discover endpoints for the API.
    """

    api_links = request.registry.api_links["v2"]

    templater = AngularRouteTemplater(
        request.route_url, params=["id", "pubid", "user", "userid", "username"]
    )

    return {"links": link_helpers.format_nested_links(api_links, templater)}
예제 #4
0
파일: index.py 프로젝트: y3g0r/h
def index(context, request):
    """Return the API descriptor document.

    Clients may use this to discover endpoints for the API.
    """

    api_links = request.registry.api_links["v1"]

    # We currently need to keep a list of the parameter names we use in our API
    # paths and pass these explicitly into the templater. As and when new
    # parameter names are added, we'll need to add them here, or this view will
    # break (and get caught by the `test_api_index` functional test).
    templater = AngularRouteTemplater(
        request.route_url,
        params=["id", "pubid", "user", "userid", "username"])

    return {"links": link_helpers.format_nested_links(api_links, templater)}
예제 #5
0
파일: index.py 프로젝트: hypothesis/h
def index(context, request):
    """Return the API descriptor document.

    Clients may use this to discover endpoints for the API.
    """

    api_links = request.registry.api_links["v1"]

    # We currently need to keep a list of the parameter names we use in our API
    # paths and pass these explicitly into the templater. As and when new
    # parameter names are added, we'll need to add them here, or this view will
    # break (and get caught by the `test_api_index` functional test).
    templater = AngularRouteTemplater(
        request.route_url, params=["id", "pubid", "user", "userid", "username"]
    )

    return {"links": link_helpers.format_nested_links(api_links, templater)}
예제 #6
0
    def test_it_nests_links_based_on_service_name_split_on_periods(
            self, templater):
        api_links = [
            _service_link(name="1"),
            _service_link(name="1.2"),
            _service_link(name="1.2.3"),
            _service_link(name="1.2.A"),
            _service_link(name="1.B"),
        ]

        formatted = links.format_nested_links([api_links], "v1", templater)

        assert "1" in formatted
        assert "2" in formatted["1"]
        assert "B" in formatted["1"]
        assert "3" in formatted["1"]["2"]
        assert "A" in formatted["1"]["2"]