'How to test HTTP endpoints in namek 2.14.1

I am beginner to Nameko framework. I have a very simple Serivce with one GET & POST endpoint, which works as expected when i run locally.

I am trying to create a test case for my Nameko service and I cant seem to find a documentation which explains clearly how I can go about it.

from nameko.web.handlers import http
import json


class SampleService:
    name = "sample_service"

    @http("GET", "/health")
    def health(self, request):
        return 200, json.dumps({'status': "healthy"})

    @http("POST", "/create")
    def create_user(self, request):
        data = request.get_json(force=True)
        print(data)
        return 200, json_dumps({'status': 'created'})

The Best reference I had for testing this was https://github.com/nameko/nameko-examples/tree/master/gateway/test/interface and I am not entirely sure if this code is up todate and can be easily replicated.

Any help on this would be much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source