本文整理汇总了Python中watcher.common.utils.generate_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python generate_uuid函数的具体用法?Python generate_uuid怎么用?Python generate_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_filter_by_goal_name
def test_filter_by_goal_name(self):
goal1 = obj_utils.create_test_goal(
self.context,
id=1,
uuid=utils.generate_uuid(),
name='My_Goal 1')
goal2 = obj_utils.create_test_goal(
self.context,
id=2,
uuid=utils.generate_uuid(),
name='My Goal 2')
for id_ in range(1, 3):
obj_utils.create_test_strategy(
self.context, id=id_,
uuid=utils.generate_uuid(),
goal_id=goal1['id'])
for id_ in range(3, 5):
obj_utils.create_test_strategy(
self.context, id=id_,
uuid=utils.generate_uuid(),
goal_id=goal2['id'])
response = self.get_json('/strategies/?goal=%s' % goal1['name'])
strategies = response['strategies']
self.assertEqual(2, len(strategies))
for strategy in strategies:
self.assertEqual(goal1['uuid'], strategy['goal_uuid'])
开发者ID:Oliverlyn,项目名称:watcher,代码行数:29,代码来源:test_strategies.py
示例2: test_filter_by_audit_template_name
def test_filter_by_audit_template_name(self):
audit_template_uuid = utils.generate_uuid()
audit_template_name = 'My_Audit_Template'
audit_template = obj_utils.create_test_audit_template(
self.context,
uuid=audit_template_uuid,
name=audit_template_name)
number_of_audits_with_audit_template_id = 5
for id_ in range(number_of_audits_with_audit_template_id):
obj_utils.create_test_audit(self.context, id=id_,
uuid=utils.generate_uuid(),
audit_template_id=audit_template.id)
for id_ in range(6, 8):
obj_utils.create_test_audit(self.context, id=id_,
uuid=utils.generate_uuid())
response = self.get_json('/audits/?audit_template=%s'
% audit_template_name)
audits = response['audits']
self.assertEqual(5, len(audits))
for audit in audits:
self.assertEqual(audit_template_uuid,
audit['audit_template_uuid'])
开发者ID:Oliverlyn,项目名称:watcher,代码行数:26,代码来源:test_audits.py
示例3: test_many_with_soft_deleted_audit_uuid
def test_many_with_soft_deleted_audit_uuid(self):
action_plan_list = []
audit1 = obj_utils.create_test_audit(self.context,
id=1,
uuid=utils.generate_uuid())
audit2 = obj_utils.create_test_audit(self.context,
id=2,
uuid=utils.generate_uuid())
for id_ in range(0, 2):
action_plan = obj_utils.create_test_action_plan(
self.context, id=id_, uuid=utils.generate_uuid(),
audit_id=audit1.id)
action_plan_list.append(action_plan.uuid)
for id_ in range(2, 4):
action_plan = obj_utils.create_test_action_plan(
self.context, id=id_, uuid=utils.generate_uuid(),
audit_id=audit2.id)
action_plan_list.append(action_plan.uuid)
self.delete('/audits/%s' % audit1.uuid)
response = self.get_json('/action_plans')
self.assertEqual(len(action_plan_list), len(response['action_plans']))
for id_ in range(0, 2):
action_plan = response['action_plans'][id_]
self.assertIsNone(action_plan['audit_uuid'])
for id_ in range(2, 4):
action_plan = response['action_plans'][id_]
self.assertEqual(audit2.uuid, action_plan['audit_uuid'])
开发者ID:j-carpentier,项目名称:watcher,代码行数:34,代码来源:test_actions_plans.py
示例4: test_get_goal_list_with_filters
def test_get_goal_list_with_filters(self):
goal1 = self._create_test_goal(
id=1,
uuid=w_utils.generate_uuid(),
name="GOAL_1",
display_name='Goal 1',
)
goal2 = self._create_test_goal(
id=2,
uuid=w_utils.generate_uuid(),
name="GOAL_2",
display_name='Goal 2',
)
res = self.dbapi.get_goal_list(self.context,
filters={'display_name': 'Goal 1'})
self.assertEqual([goal1['uuid']], [r.uuid for r in res])
res = self.dbapi.get_goal_list(self.context,
filters={'display_name': 'Goal 3'})
self.assertEqual([], [r.uuid for r in res])
res = self.dbapi.get_goal_list(
self.context, filters={'name': 'GOAL_1'})
self.assertEqual([goal1['uuid']], [r.uuid for r in res])
res = self.dbapi.get_goal_list(
self.context,
filters={'display_name': 'Goal 2'})
self.assertEqual([goal2['uuid']], [r.uuid for r in res])
开发者ID:shanling2004,项目名称:watcher,代码行数:30,代码来源:test_goal.py
示例5: test_execute_force_dummy
def test_execute_force_dummy(self):
obj_utils.create_test_goal(self.context, id=50,
uuid=utils.generate_uuid(),
name="my_goal")
strategy = obj_utils.create_test_strategy(self.context,
id=42,
uuid=utils.generate_uuid(),
name="dummy")
audit_template = obj_utils.create_test_audit_template(
self.context,
uuid=utils.generate_uuid(),
strategy_id=strategy.id,
name="my_template")
audit = obj_utils.create_test_audit(
self.context,
audit_template_id=audit_template.id,
uuid=utils.generate_uuid(),
)
solution = self.strategy_context.execute_strategy(
audit.uuid, self.context)
self.assertEqual(len(solution.actions), 3)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:26,代码来源:test_strategy_context.py
示例6: test_execute_force_basic
def test_execute_force_basic(self, mock_call):
expected_strategy = "basic"
mock_call.return_value = expected_strategy
obj_utils.create_test_goal(self.context, id=50,
uuid=utils.generate_uuid(),
name="my_goal")
strategy = obj_utils.create_test_strategy(self.context,
id=42,
uuid=utils.generate_uuid(),
name=expected_strategy)
audit_template = obj_utils.create_test_audit_template(
self.context,
uuid=utils.generate_uuid(),
strategy_id=strategy.id,
name="my_template")
audit = obj_utils.create_test_audit(
self.context,
audit_template_id=audit_template.id,
uuid=utils.generate_uuid(),
)
solution = self.strategy_context.execute_strategy(
audit.uuid, self.context)
self.assertEqual(solution, expected_strategy)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:29,代码来源:test_strategy_context.py
示例7: test_get_scoring_engine_list_with_filters
def test_get_scoring_engine_list_with_filters(self):
scoring_engine1 = self._create_test_scoring_engine(
id=1,
uuid=w_utils.generate_uuid(),
name="SE_ID_1",
description='ScoringEngine 1',
metainfo="a1=b1",
)
scoring_engine2 = self._create_test_scoring_engine(
id=2,
uuid=w_utils.generate_uuid(),
name="SE_ID_2",
description='ScoringEngine 2',
metainfo="a2=b2",
)
res = self.dbapi.get_scoring_engine_list(
self.context, filters={'description': 'ScoringEngine 1'})
self.assertEqual([scoring_engine1['name']], [r.name for r in res])
res = self.dbapi.get_scoring_engine_list(
self.context, filters={'description': 'ScoringEngine 3'})
self.assertEqual([], [r.name for r in res])
res = self.dbapi.get_scoring_engine_list(
self.context,
filters={'description': 'ScoringEngine 2'})
self.assertEqual([scoring_engine2['name']], [r.name for r in res])
开发者ID:j-carpentier,项目名称:watcher,代码行数:28,代码来源:test_scoring_engine.py
示例8: test_get_audit_list_with_filters
def test_get_audit_list_with_filters(self):
audit1 = self._create_test_audit(
id=1,
type='ONESHOT',
uuid=w_utils.generate_uuid(),
deadline=None,
state='ONGOING')
audit2 = self._create_test_audit(
id=2,
type='CONTINUOUS',
uuid=w_utils.generate_uuid(),
deadline=None,
state='PENDING')
res = self.dbapi.get_audit_list(self.context,
filters={'type': 'ONESHOT'})
self.assertEqual([audit1['id']], [r.id for r in res])
res = self.dbapi.get_audit_list(self.context,
filters={'type': 'bad-type'})
self.assertEqual([], [r.id for r in res])
res = self.dbapi.get_audit_list(
self.context,
filters={'state': 'ONGOING'})
self.assertEqual([audit1['id']], [r.id for r in res])
res = self.dbapi.get_audit_list(
self.context,
filters={'state': 'PENDING'})
self.assertEqual([audit2['id']], [r.id for r in res])
开发者ID:Jean-Emile,项目名称:watcher,代码行数:31,代码来源:test_audit.py
示例9: _data_setup
def _data_setup(self):
strategy1_name = "STRATEGY_ID_1"
strategy2_name = "STRATEGY_ID_2"
strategy3_name = "STRATEGY_ID_3"
self.goal1 = utils.create_test_goal(
id=1, uuid=w_utils.generate_uuid(),
name="GOAL_ID", display_name="Goal")
self.goal2 = utils.create_test_goal(
id=2, uuid=w_utils.generate_uuid(),
name="DUMMY", display_name="Dummy")
with freezegun.freeze_time(self.FAKE_TODAY):
self.strategy1 = utils.create_test_strategy(
id=1, uuid=w_utils.generate_uuid(),
name=strategy1_name, display_name="Strategy 1",
goal_id=self.goal1.id)
with freezegun.freeze_time(self.FAKE_OLD_DATE):
self.strategy2 = utils.create_test_strategy(
id=2, uuid=w_utils.generate_uuid(),
name=strategy2_name, display_name="Strategy 2",
goal_id=self.goal1.id)
with freezegun.freeze_time(self.FAKE_OLDER_DATE):
self.strategy3 = utils.create_test_strategy(
id=3, uuid=w_utils.generate_uuid(),
name=strategy3_name, display_name="Strategy 3",
goal_id=self.goal2.id)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:27,代码来源:test_strategy.py
示例10: test_get_strategy_list_with_filters
def test_get_strategy_list_with_filters(self):
strategy1 = self._create_test_strategy(
id=1,
uuid=w_utils.generate_uuid(),
name="STRATEGY_ID_1",
display_name='Strategy 1',
)
strategy2 = self._create_test_strategy(
id=2,
uuid=w_utils.generate_uuid(),
name="STRATEGY_ID_2",
display_name='Strategy 2',
)
res = self.dbapi.get_strategy_list(
self.context, filters={'display_name': 'Strategy 1'})
self.assertEqual([strategy1['uuid']], [r.uuid for r in res])
res = self.dbapi.get_strategy_list(
self.context, filters={'display_name': 'Strategy 3'})
self.assertEqual([], [r.uuid for r in res])
res = self.dbapi.get_strategy_list(
self.context,
filters={'goal_id': 1})
self.assertEqual([strategy1['uuid'], strategy2['uuid']],
[r.uuid for r in res])
res = self.dbapi.get_strategy_list(
self.context,
filters={'display_name': 'Strategy 2'})
self.assertEqual([strategy2['uuid']], [r.uuid for r in res])
开发者ID:Oliverlyn,项目名称:watcher,代码行数:32,代码来源:test_strategy.py
示例11: setUp
def setUp(self):
super(TestAuditTemplateObject, self).setUp()
self.fake_audit_template = utils.get_test_audit_template()
self.fake_goal1 = utils.create_test_goal(
id=1, uuid=w_utils.generate_uuid(), name="DUMMY")
self.fake_goal2 = utils.create_test_goal(
id=2, uuid=w_utils.generate_uuid(), name="BALANCE_LOAD")
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:test_audit_template.py
示例12: test_get_audit_list_with_filter_by_audit_template_name
def test_get_audit_list_with_filter_by_audit_template_name(self):
audit_template = self.dbapi.create_audit_template(
utils.get_test_audit_template(
uuid=w_utils.generate_uuid(),
name='My Audit Template 1',
description='Description of my audit template 1',
host_aggregate=5,
goal='DUMMY',
extra={'automatic': True})
)
audit = self._create_test_audit(
type='ONESHOT',
uuid=w_utils.generate_uuid(),
deadline=None,
state='ONGOING',
audit_template_id=audit_template.id)
res = self.dbapi.get_audit_list(
self.context,
filters={'audit_template_name': audit_template.name})
for r in res:
self.assertEqual(audit['audit_template_id'], r.audit_template_id)
开发者ID:Jean-Emile,项目名称:watcher,代码行数:25,代码来源:test_audit.py
示例13: test_get_action_list_with_filters
def test_get_action_list_with_filters(self):
audit = utils.create_test_audit(uuid=w_utils.generate_uuid())
action_plan = self._create_test_action_plan(
id=1,
uuid=w_utils.generate_uuid(),
audit_id=audit.id,
first_action_id=None,
state='RECOMMENDED')
action1 = self._create_test_action(
id=1,
action_plan_id=1,
description='description action 1',
uuid=w_utils.generate_uuid(),
next=None,
state='PENDING',
alarm=None)
action2 = self._create_test_action(
id=2,
action_plan_id=2,
description='description action 2',
uuid=w_utils.generate_uuid(),
next=action1['uuid'],
state='PENDING',
alarm=None)
action3 = self._create_test_action(
id=3,
action_plan_id=1,
description='description action 3',
uuid=w_utils.generate_uuid(),
next=action2['uuid'],
state='ONGOING',
alarm=None)
res = self.dbapi.get_action_list(self.context,
filters={'state': 'ONGOING'})
self.assertEqual([action3['id']], [r.id for r in res])
res = self.dbapi.get_action_list(self.context,
filters={'state': 'bad-state'})
self.assertEqual([], [r.id for r in res])
res = self.dbapi.get_action_list(
self.context,
filters={'action_plan_id': 2})
self.assertEqual([action2['id']], [r.id for r in res])
res = self.dbapi.get_action_list(
self.context,
filters={'action_plan_uuid': action_plan['uuid']})
self.assertEqual(
[action1['id'], action3['id']].sort(),
[r.id for r in res].sort())
res = self.dbapi.get_action_list(
self.context,
filters={'audit_uuid': audit.uuid})
for action in res:
self.assertEqual(action_plan['id'], action.action_plan_id)
开发者ID:XroLLla,项目名称:watcher,代码行数:57,代码来源:test_action.py
示例14: test_audit_template_create_same_name
def test_audit_template_create_same_name(self):
audit_template1 = utils.create_test_audit_template(
uuid=w_utils.generate_uuid(),
name='audit_template_name')
self.assertEqual(audit_template1['uuid'], audit_template1.uuid)
self.assertRaises(
exception.AuditTemplateAlreadyExists,
utils.create_test_audit_template,
uuid=w_utils.generate_uuid(),
name='audit_template_name')
开发者ID:Oliverlyn,项目名称:watcher,代码行数:10,代码来源:test_audit_template.py
示例15: test_filter_by_action_plan_and_audit_uuids
def test_filter_by_action_plan_and_audit_uuids(self):
audit = obj_utils.create_test_audit(
self.context, uuid=utils.generate_uuid())
action_plan = obj_utils.create_test_action_plan(
self.context,
uuid=utils.generate_uuid(),
audit_id=audit.id)
url = '/actions?action_plan_uuid=%s&audit_uuid=%s' % (
action_plan.uuid, audit.uuid)
response = self.get_json(url, expect_errors=True)
self.assertEqual(400, response.status_int)
开发者ID:XroLLla,项目名称:watcher,代码行数:11,代码来源:test_actions.py
示例16: test_many_with_audit_uuid
def test_many_with_audit_uuid(self):
action_plan_list = []
audit = obj_utils.create_test_audit(self.context,
uuid=utils.generate_uuid())
for id_ in range(5):
action_plan = obj_utils.create_test_action_plan(
self.context, id=id_, uuid=utils.generate_uuid(),
audit_id=audit.id)
action_plan_list.append(action_plan.uuid)
response = self.get_json('/action_plans')
self.assertEqual(len(action_plan_list), len(response['action_plans']))
for action in response['action_plans']:
self.assertEqual(audit.uuid, action['audit_uuid'])
开发者ID:j-carpentier,项目名称:watcher,代码行数:13,代码来源:test_actions_plans.py
示例17: _data_setup
def _data_setup(self):
with freezegun.freeze_time(self.FAKE_TODAY):
self.goal1 = utils.create_test_goal(
id=1, uuid=w_utils.generate_uuid(), name="GOAL_1",
display_name="Goal 1")
with freezegun.freeze_time(self.FAKE_OLD_DATE):
self.goal2 = utils.create_test_goal(
id=2, uuid=w_utils.generate_uuid(),
name="GOAL_2", display_name="Goal 2")
with freezegun.freeze_time(self.FAKE_OLDER_DATE):
self.goal3 = utils.create_test_goal(
id=3, uuid=w_utils.generate_uuid(),
name="GOAL_3", display_name="Goal 3")
开发者ID:shanling2004,项目名称:watcher,代码行数:13,代码来源:test_goal.py
示例18: test_many_without_soft_deleted
def test_many_without_soft_deleted(self):
action_list = []
for id_ in [1, 2, 3]:
action = obj_utils.create_test_action(self.context, id=id_,
uuid=utils.generate_uuid())
action_list.append(action.uuid)
for id_ in [4, 5]:
action = obj_utils.create_test_action(self.context, id=id_,
uuid=utils.generate_uuid())
action.soft_delete()
response = self.get_json('/actions')
self.assertEqual(3, len(response['actions']))
uuids = [s['uuid'] for s in response['actions']]
self.assertEqual(sorted(action_list), sorted(uuids))
开发者ID:XroLLla,项目名称:watcher,代码行数:14,代码来源:test_actions.py
示例19: test_JSONEncodedDict_default_value
def test_JSONEncodedDict_default_value(self):
# Create audit_template w/o extra
audit_template1_id = w_utils.generate_uuid()
self.dbapi.create_audit_template({'uuid': audit_template1_id})
audit_template1 = sa_api.model_query(models.AuditTemplate) \
.filter_by(uuid=audit_template1_id).one()
self.assertEqual({}, audit_template1.extra)
# Create audit_template with extra
audit_template2_id = w_utils.generate_uuid()
self.dbapi.create_audit_template({'uuid': audit_template2_id,
'extra': {'bar': 'foo'}})
audit_template2 = sa_api.model_query(models.AuditTemplate) \
.filter_by(uuid=audit_template2_id).one()
self.assertEqual('foo', audit_template2.extra['bar'])
开发者ID:Jean-Emile,项目名称:watcher,代码行数:15,代码来源:test_types.py
示例20: test_many_with_sort_key_audit_uuid
def test_many_with_sort_key_audit_uuid(self):
audit_list = []
for id_ in range(5):
audit = obj_utils.create_test_audit(self.context,
uuid=utils.generate_uuid())
obj_utils.create_test_action_plan(
self.context, id=id_, uuid=utils.generate_uuid(),
audit_id=audit.id)
audit_list.append(audit.uuid)
response = self.get_json('/action_plans/?sort_key=audit_uuid')
self.assertEqual(5, len(response['action_plans']))
uuids = [s['audit_uuid'] for s in response['action_plans']]
self.assertEqual(sorted(audit_list), uuids)
开发者ID:j-carpentier,项目名称:watcher,代码行数:15,代码来源:test_actions_plans.py
注:本文中的watcher.common.utils.generate_uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论