def test_list_uptime_check_configs(self): # Setup Expected Response next_page_token = "" total_size = 705419236 uptime_check_configs_element = {} uptime_check_configs = [uptime_check_configs_element] expected_response = { "next_page_token": next_page_token, "total_size": total_size, "uptime_check_configs": uptime_check_configs, } expected_response = uptime_service_pb2.ListUptimeCheckConfigsResponse( **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() # Setup Request parent = client.project_path("[PROJECT]") paged_list_response = client.list_uptime_check_configs(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.uptime_check_configs[0] == resources[0] assert len(channel.requests) == 1 expected_request = uptime_service_pb2.ListUptimeCheckConfigsRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_list_uptime_check_configs(self): # Setup Expected Response next_page_token = '' uptime_check_configs_element = {} uptime_check_configs = [uptime_check_configs_element] expected_response = { 'next_page_token': next_page_token, 'uptime_check_configs': uptime_check_configs } expected_response = uptime_service_pb2.ListUptimeCheckConfigsResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = monitoring_v3.UptimeCheckServiceClient(channel=channel) # Setup Request parent = client.project_path('[PROJECT]') paged_list_response = client.list_uptime_check_configs(parent) resources = list(paged_list_response) assert len(resources) == 1 assert expected_response.uptime_check_configs[0] == resources[0] assert len(channel.requests) == 1 expected_request = uptime_service_pb2.ListUptimeCheckConfigsRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request