def test_update_source(self): # Setup Expected Response name = "name3373707" display_name = "displayName1615086568" description = "description-1724546052" expected_response = { "name": name, "display_name": display_name, "description": description, } expected_response = source_pb2.Source(**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 = securitycenter_v1beta1.SecurityCenterClient() # Setup Request source = {} response = client.update_source(source) assert expected_response == response assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.UpdateSourceRequest( source=source) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_source(self): # Setup Expected Response name_2 = "name2-1052831874" display_name = "displayName1615086568" description = "description-1724546052" expected_response = { "name": name_2, "display_name": display_name, "description": description, } expected_response = source_pb2.Source(**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 = securitycenter_v1beta1.SecurityCenterClient() # Setup Request name = client.source_path("[ORGANIZATION]", "[SOURCE]") response = client.get_source(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.GetSourceRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_source(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name, 'display_name': display_name, 'description': description } expected_response = source_pb2.Source(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = securitycenter_v1beta1.SecurityCenterClient(channel=channel) # Setup Request source = {} response = client.update_source(source) assert expected_response == response assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.UpdateSourceRequest( source=source) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_create_source(self): # Setup Expected Response name = 'name3373707' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name, 'display_name': display_name, 'description': description } expected_response = source_pb2.Source(**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 = securitycenter_v1beta1.SecurityCenterClient() # Setup Request parent = client.organization_path('[ORGANIZATION]') source = {} response = client.create_source(parent, source) assert expected_response == response assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.CreateSourceRequest( parent=parent, source=source) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_get_source(self): # Setup Expected Response name_2 = 'name2-1052831874' display_name = 'displayName1615086568' description = 'description-1724546052' expected_response = { 'name': name_2, 'display_name': display_name, 'description': description } expected_response = source_pb2.Source(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = securitycenter_v1beta1.SecurityCenterClient(channel=channel) # Setup Request name = client.source_path('[ORGANIZATION]', '[SOURCE]') response = client.get_source(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.GetSourceRequest( name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request