def test_create_scan_config(self): # Setup Expected Response name = "name3373707" display_name = "displayName1615086568" max_qps = 844445913 expected_response = { "name": name, "display_name": display_name, "max_qps": max_qps, } expected_response = scan_config_pb2.ScanConfig(**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 = websecurityscanner_v1alpha.WebSecurityScannerClient() # Setup Request parent = client.project_path("[PROJECT]") scan_config = {} response = client.create_scan_config(parent, scan_config) assert expected_response == response assert len(channel.requests) == 1 expected_request = web_security_scanner_pb2.CreateScanConfigRequest( parent=parent, scan_config=scan_config) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_scan_config(self): # Setup Expected Response name_2 = "name2-1052831874" display_name = "displayName1615086568" max_qps = 844445913 expected_response = { "name": name_2, "display_name": display_name, "max_qps": max_qps, } expected_response = scan_config_pb2.ScanConfig(**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 = websecurityscanner_v1alpha.WebSecurityScannerClient() # Setup Request name = client.scan_config_path("[PROJECT]", "[SCAN_CONFIG]") response = client.get_scan_config(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = web_security_scanner_pb2.GetScanConfigRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_scan_config(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' max_qps = 844445913 expected_response = { 'name': name, 'display_name': display_name, 'max_qps': max_qps } expected_response = scan_config_pb2.ScanConfig(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = websecurityscanner_v1alpha.WebSecurityScannerClient( channel=channel) # Setup Request parent = client.project_path('[PROJECT]') scan_config = {} response = client.create_scan_config(parent, scan_config) assert expected_response == response assert len(channel.requests) == 1 expected_request = web_security_scanner_pb2.CreateScanConfigRequest( parent=parent, scan_config=scan_config) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_scan_config(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' max_qps = 844445913 expected_response = { 'name': name, 'display_name': display_name, 'max_qps': max_qps } expected_response = scan_config_pb2.ScanConfig(**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 = websecurityscanner_v1alpha.WebSecurityScannerClient() # Setup Request scan_config = {} update_mask = {} response = client.update_scan_config(scan_config, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = web_security_scanner_pb2.UpdateScanConfigRequest( scan_config=scan_config, update_mask=update_mask) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_scan_config(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' max_qps = 844445913 expected_response = { 'name': name_2, 'display_name': display_name, 'max_qps': max_qps } expected_response = scan_config_pb2.ScanConfig(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = websecurityscanner_v1alpha.WebSecurityScannerClient( channel=channel) # Setup Request name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]') response = client.get_scan_config(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = web_security_scanner_pb2.GetScanConfigRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request