Skip to content

Commit

Permalink
[kms] fix: use unique ids for test [(#3563)](GoogleCloudPlatform/pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo authored and busunkim96 committed Jun 4, 2020
1 parent d968ba5 commit 6a0ebf7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/google-cloud-kms/samples/snippets/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import time
from os import environ
import uuid

from google.api_core.exceptions import Aborted, GoogleAPICallError
from google.cloud import kms_v1
Expand Down Expand Up @@ -63,7 +64,7 @@ def setup_module(module):

class TestKMSSnippets:
project_id = environ['GCLOUD_PROJECT']
keyring_id = 'kms-samples'
keyring_id = 'kms-samples-{}'.format(uuid.uuid4().hex)
location = 'global'
parent = 'projects/{}/locations/{}'.format(project_id, location)
keyring_path = '{}/keyRings/{}'.format(parent, keyring_id)
Expand All @@ -83,7 +84,7 @@ class TestKMSSnippets:
@pytest.mark.skip(reason="There's currently no method to delete keyrings, \
so we should avoid creating resources")
def test_create_key_ring(self):
ring_id = self.keyring_id + '-testcreate' + str(int(time.time()))
ring_id = self.keyring_id + '-test-create-{}'.format(uuid.uuid4().hex)
snippets.create_key_ring(self.project_id, self.location, ring_id)
client = kms_v1.KeyManagementServiceClient()
result = client.get_key_ring(client.key_ring_path(self.project_id,
Expand All @@ -94,7 +95,7 @@ def test_create_key_ring(self):
@pytest.mark.skip(reason="Deleting keys isn't instant, so we should avoid \
creating a large number of them in our tests")
def test_create_crypto_key(self):
key_id = self.sym_id + '-test' + str(int(time.time()))
key_id = self.sym_id + '-test-{}'.format(uuid.uuid4().hex)
snippets.create_crypto_key(self.project_id, self.location,
self.keyring_id, key_id)
c = kms_v1.KeyManagementServiceClient()
Expand Down

0 comments on commit 6a0ebf7

Please sign in to comment.