Replace uuid.uuid4() with uuidutils.generate_uuid()
Since oslo.utils provide the ability to generate the uuid string, and some others use oslo.utils[0] too. For consistency, this ps replaces uuid.uuid4() with uuidutils.generate_uuid(). [0]: https://github.com/openstack/qinling/blob/master/qinling/api/controllers/v1/types.py#L16 Change-Id: Iba01711dfadb36e2090926c2c7452ff62362b57b
This commit is contained in:
parent
1be8f87390
commit
ec36b22748
@ -11,10 +11,10 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from qinling.tests.unit.api import base
|
from qinling.tests.unit.api import base
|
||||||
|
|
||||||
TEST_CASE_NAME = 'TestFunctionWorkerController'
|
TEST_CASE_NAME = 'TestFunctionWorkerController'
|
||||||
@ -23,7 +23,7 @@ TEST_CASE_NAME = 'TestFunctionWorkerController'
|
|||||||
class TestFunctionWorkerController(base.APITest):
|
class TestFunctionWorkerController(base.APITest):
|
||||||
@mock.patch('qinling.utils.etcd_util.get_workers')
|
@mock.patch('qinling.utils.etcd_util.get_workers')
|
||||||
def test_get_all_workers(self, mock_get_workers):
|
def test_get_all_workers(self, mock_get_workers):
|
||||||
function_id = str(uuid.uuid4())
|
function_id = uuidutils.generate_uuid()
|
||||||
mock_get_workers.return_value = ['test_worker0', 'test_worker1']
|
mock_get_workers.return_value = ['test_worker0', 'test_worker1']
|
||||||
|
|
||||||
resp = self.app.get('/v1/functions/%s/workers' % function_id)
|
resp = self.app.get('/v1/functions/%s/workers' % function_id)
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
import etcd3gw
|
import etcd3gw
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
CLIENT = None
|
CLIENT = None
|
||||||
@ -39,7 +38,7 @@ def get_worker_lock():
|
|||||||
def create_worker(function_id, worker):
|
def create_worker(function_id, worker):
|
||||||
client = get_client()
|
client = get_client()
|
||||||
client.create(
|
client.create(
|
||||||
'%s/worker_%s' % (function_id, str(uuid.uuid4())),
|
'%s/worker_%s' % (function_id, uuidutils.generate_uuid()),
|
||||||
worker
|
worker
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user