Complete the code to define an integration test that checks communication between two microservices.
def test_service_communication(): response = service_a.call_service_b() assert response.status_code == [1]
The HTTP status code 200 means the request was successful, which is expected in a successful integration test.
Complete the code to mock a dependent microservice during integration testing.
with mock.patch('service_b.api_call') as mocked_call: mocked_call.return_value = [1] result = service_a.call_service_b() assert result == 'success'
Mocking the dependent service to return 'success' simulates a positive response for integration testing.
Fix the error in the integration test setup to correctly start the test environment.
def setup_test_env(): [1].start() service_a.reset() service_b.reset()
The variable 'test_env' correctly refers to the test environment object that needs to be started.
Fill both blanks to create a test that waits for service B to be ready before calling it.
def test_service_b_ready(): while not service_b.[1](): time.[2](1) response = service_a.call_service_b() assert response.status_code == 200
Use 'is_ready' to check if service B is ready and 'sleep' to pause the loop for 1 second.
Fill all three blanks to build a dictionary comprehension that maps service names to their health status if status is 'healthy'.
health_status = { [1]: status for [2], status in services.items() if status [3] 'healthy' }The comprehension maps each service name to its status only if the status equals 'healthy'.