def test_list_uptime_check_ips(self): # Setup Expected Response next_page_token = "" uptime_check_ips_element = {} uptime_check_ips = [uptime_check_ips_element] expected_response = { "next_page_token": next_page_token, "uptime_check_ips": uptime_check_ips, } expected_response = uptime_service_pb2.ListUptimeCheckIpsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = monitoring_v3.UptimeCheckServiceClient() paged_list_response = client.list_uptime_check_ips() resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.uptime_check_ips[0] == resources[0] assert len(channel.requests) == 1 expected_request = uptime_service_pb2.ListUptimeCheckIpsRequest() actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_uptime_check_ips(self): # Setup Expected Response next_page_token = '' uptime_check_ips_element = {} uptime_check_ips = [uptime_check_ips_element] expected_response = { 'next_page_token': next_page_token, 'uptime_check_ips': uptime_check_ips } expected_response = uptime_service_pb2.ListUptimeCheckIpsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = monitoring_v3.UptimeCheckServiceClient(channel=channel) paged_list_response = client.list_uptime_check_ips() resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.uptime_check_ips[0] == resources[0] assert len(channel.requests) == 1 expected_request = uptime_service_pb2.ListUptimeCheckIpsRequest() actual_request = channel.requests[0][1] assert expected_request == actual_request