def test_run_asset_discovery(self): # Setup Expected Response expected_response = {} expected_response = empty_pb2.Empty(**expected_response) operation = operations_pb2.Operation( name="operations/test_run_asset_discovery", done=True) operation.response.Pack(expected_response) # Mock the API response channel = ChannelStub(responses=[operation]) 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]") response = client.run_asset_discovery(parent) result = response.result() assert expected_response == result assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.RunAssetDiscoveryRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_run_asset_discovery(self): # Setup Expected Response expected_response = {} expected_response = empty_pb2.Empty(**expected_response) operation = operations_pb2.Operation( name='operations/test_run_asset_discovery', done=True) operation.response.Pack(expected_response) # Mock the API response channel = ChannelStub(responses=[operation]) client = securitycenter_v1beta1.SecurityCenterClient(channel=channel) # Setup Request parent = client.organization_path('[ORGANIZATION]') response = client.run_asset_discovery(parent) result = response.result() assert expected_response == result assert len(channel.requests) == 1 expected_request = securitycenter_service_pb2.RunAssetDiscoveryRequest( parent=parent) actual_request = channel.requests[0][1] assert expected_request == actual_request