The test process at this time receives new element integration. We need to validate that the minimum functionalities for the full operation of the business are being met. For this, we have two basic approaches—functional testing of each microservice and integrated testing of microservices.
The functional test will prove whether a microservice performs its function perfectly. Again, let's take the microservice famous_news_service
as an example, where we will write the tests of the command layer.
First, we will declare imports in the tests.py
file. Nameko has good support testing and provides the worker_factory
function, which causes the elements identified by Nameko to be performed without using a real server:
import os
import pytest
from .service import Command
from nameko.testing.services import worker_factory
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
After the imports declaration, we'll create a fixture...