Exemplo n.º 1
0
 def create_endpoint(function):
     return Endpoint(
         "/v1/test/open/api",
         "GET",
         function,
         decorator(function),
     )
Exemplo n.º 2
0
 def create_endpoint(function, method, callback):
     return Endpoint(
         "/v1/test/open/api",
         "GET",
         function,
         decorator(function),
         callback=callback,
     )
Exemplo n.º 3
0
 def create_endpoint(function, callback):
     return Endpoint(
         "/v1/test/open/api",
         "GET",
         function,
         decorator(function),
         callback=callback,
         response_code=200,
     )
Exemplo n.º 4
0
    def test_docstring_endpoint_function(self):
        instance = Endpoint(
            self.route,
            self.method,
            self.docstring_function,
            self.decorated_docstring_function,
        )

        assert instance.docstring == "This is a test docstring!"
Exemplo n.º 5
0
 def test_endpoint_callback_response_code(self):
     instance = Endpoint(
         self.route,
         self.method,
         self.function,
         self.decorated_function,
         callback=True,
         response_code=self.response_code,
     )
     assert instance.callback is True
     assert instance.response_code != self.response_code
     assert instance.response_code == 202
Exemplo n.º 6
0
    def test_endpoint_instance_creation(self):
        instance = Endpoint(
            self.route,
            self.method,
            self.function,
            self.decorated_function,
            response_code=self.response_code,
        )

        assert isinstance(instance, Endpoint) is True
        assert instance.route == self.route
        assert instance.method == self.method
        assert instance.function == self.function
        assert instance.docstring == "No description provided."
        assert instance.callback is False
        assert instance.response_code == self.response_code
Exemplo n.º 7
0
    def test_get_complete_endpoint(self):
        self.endpoints._Endpoints__create_route(self.route)
        route = self.endpoints._Endpoints__get_route(self.route)
        assert route == {}

        endpoint_object = Endpoint(
            self.route,
            self.methods[0],
            self.function,
            self.decorated_function,
        )

        route[self.methods[0]] = endpoint_object

        endpoint = self.endpoints._Endpoints__get_endpoint(self.route, self.methods[0])
        assert isinstance(endpoint, Endpoint)