Unit-testing a Nameko microservice

According to the documentation, http://url.marcuspen.com/nameko, Nameko is:

"A microservices framework for Python that lets service developers concentrate on application logic and encourages testability."

We will now focus on the testability part of Nameko; it provides some very useful tools for isolating and testing its services.

Create a new folder, tests, and place two new files inside, __init__.py (which can be left blank) and test_service.py:

from nameko.testing.services import worker_factory 
from temp_messenger.service import KonnichiwaService 
 
def test_konnichiwa(): 
    service = worker_factory(KonnichiwaService) 
    result = service.konnichiwa() 
    assert result == 'Konnichiwa!' 

When running outside of the ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.