Merge "Add general function for generating random names"

This commit is contained in:
Jenkins 2015-02-21 01:00:44 +00:00 committed by Gerrit Code Review
commit 0bf58f63af
4 changed files with 24 additions and 9 deletions

View File

@ -11,6 +11,8 @@
# under the License.
import os
import time
import uuid
import testtools
import xvfbwrapper
@ -20,6 +22,25 @@ from openstack_dashboard.test.integration_tests.pages import loginpage
from openstack_dashboard.test.integration_tests import webdriver
def gen_random_resource_name(resource="", timestamp=True):
"""Generate random resource name using uuid and timestamp.
Input fields are usually limited to 255 or 80 characters hence their
provide enough space for quite long resource names, but it might be
the case that maximum field length is quite restricted, it is then
necessary to consider using shorter resource argument or avoid using
timestamp by setting timestamp argument to False.
"""
fields = ["horizon"]
if resource:
fields.append(resource)
if timestamp:
tstamp = time.strftime("%d-%m-%H-%M-%S")
fields.append(tstamp)
fields.append(str(uuid.uuid4()).replace("-", ""))
return "_".join(fields)
class BaseTestCase(testtools.TestCase):
def setUp(self):

View File

@ -10,13 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from openstack_dashboard.test.integration_tests import helpers
class TestFlavors(helpers.AdminTestCase):
FLAVOR_NAME = 'horizonflavor_' + str(uuid.uuid4())
FLAVOR_NAME = helpers.gen_random_resource_name("flavor")
def test_flavor_create(self):
"""tests the flavor creation and deletion functionalities:

View File

@ -10,13 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from openstack_dashboard.test.integration_tests import helpers
class TestImage(helpers.TestCase):
IMAGE_NAME = 'horizonimage_' + str(uuid.uuid4())
IMAGE_NAME = helpers.gen_random_resource_name("image")
def test_image_create_delete(self):
"""tests the image creation and deletion functionalities:

View File

@ -13,14 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from openstack_dashboard.test.integration_tests import helpers
class TestKeypair(helpers.TestCase):
"""Checks that the user is able to create/delete keypair."""
KEYPAIR_NAME = 'horizonkeypair_' + str(uuid.uuid4())
KEYPAIR_NAME = helpers.gen_random_resource_name("keypair")
def test_keypair(self):
keypair_page = self.home_pg.go_to_accessandsecurity_keypairspage()