def test_must_print_routes(self):
        host = "host"
        port = 123

        api_provider = Mock()
        apis = [
            Api(path="/1", method="GET", function_name="name1", cors="CORS1"),
            Api(path="/1", method="POST", function_name="name1", cors="CORS1"),
            Api(path="/1",
                method="DELETE",
                function_name="othername1",
                cors="CORS1"),
            Api(path="/2", method="GET2", function_name="name2", cors="CORS2"),
            Api(path="/3", method="GET3", function_name="name3", cors="CORS3"),
        ]
        api_provider.get_all.return_value = apis

        expected = {
            "Mounting name1 at http://host:123/1 [GET, POST]",
            "Mounting othername1 at http://host:123/1 [DELETE]",
            "Mounting name2 at http://host:123/2 [GET2]",
            "Mounting name3 at http://host:123/3 [GET3]"
        }

        actual = LocalApiService._print_routes(api_provider, host, port)
        self.assertEquals(expected, set(actual))
Пример #2
0
    def test_must_print_routes(self):
        host = "host"
        port = 123

        apis = [
            Route(path="/1", methods=["GET"], function_name="name1"),
            Route(path="/1", methods=["POST"], function_name="name1"),
            Route(path="/1", methods=["DELETE"], function_name="othername1"),
            Route(path="/2", methods=["GET2"], function_name="name2"),
            Route(path="/3", methods=["GET3"], function_name="name3"),
        ]
        apis = ApiCollector.dedupe_function_routes(apis)
        expected = {"Mounting name1 at http://host:123/1 [GET, POST]",
                    "Mounting othername1 at http://host:123/1 [DELETE]",
                    "Mounting name2 at http://host:123/2 [GET2]",
                    "Mounting name3 at http://host:123/3 [GET3]"}

        actual = LocalApiService._print_routes(apis, host, port)
        self.assertEquals(expected, set(actual))