Refactor UUID test

Oslo is removing uuidutils during the icehouse cycle. We had removed
uuidutils.generate_uuid() in https://review.openstack.org/#/c/60643/
It seems the UUID test was not executed, for example, there is no method
called generate_uuid() in common/utils, the Jekins still passed. This
patch move the testcase and remove the test method for generate_uuid.

Change-Id: If4f508129f0b44d63fe77ed1251c0e0737e7e897
Partial-Bug: #1253497
This commit is contained in:
ChangBo Guo(gcb) 2014-02-26 14:25:15 +08:00
parent 01903933db
commit 3216541561
2 changed files with 13 additions and 21 deletions

View File

@ -15,6 +15,7 @@
import os
import tempfile
import uuid
import six
import webob
@ -215,3 +216,15 @@ class TestUtils(test_utils.BaseTestCase):
self.assertRaises(RuntimeError,
utils.validate_key_cert,
keyf.name, keyf.name)
class UUIDTestCase(test_utils.BaseTestCase):
def test_is_uuid_like(self):
self.assertTrue(utils.is_uuid_like(str(uuid.uuid4())))
def test_id_is_uuid_like(self):
self.assertFalse(utils.is_uuid_like(1234567))
def test_name_is_uuid_like(self):
self.assertFalse(utils.is_uuid_like('zhongyueluo'))

View File

@ -22,7 +22,6 @@ import shlex
import shutil
import socket
import subprocess
import uuid
import fixtures
from oslo.config import cfg
@ -34,7 +33,6 @@ import webob
from glance.common import config
from glance.common import exception
from glance.common import property_utils
from glance.common import utils
from glance.common import wsgi
from glance import context
from glance.db.sqlalchemy import api as db_api
@ -562,22 +560,3 @@ class HttplibWsgiAdapter(object):
response = self.req.get_response(self.app)
return FakeHTTPResponse(response.status_code, response.headers,
response.body)
class UUIDTestCase(testtools.TestCase):
def test_generate_uuid(self):
uuid_string = utils.generate_uuid()
self.assertIsInstance(uuid_string, str)
self.assertEqual(len(uuid_string), 36)
# make sure there are 4 dashes
self.assertEqual(len(uuid_string.replace('-', '')), 32)
def test_is_uuid_like(self):
self.assertTrue(utils.is_uuid_like(str(uuid.uuid4())))
def test_id_is_uuid_like(self):
self.assertFalse(utils.is_uuid_like(1234567))
def test_name_is_uuid_like(self):
self.assertFalse(utils.is_uuid_like('zhongyueluo'))