本文整理汇总了Python中integration.ggrc_workflows.generator.WorkflowsGenerator.modify_workflow方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowsGenerator.modify_workflow方法的具体用法?Python WorkflowsGenerator.modify_workflow怎么用?Python WorkflowsGenerator.modify_workflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类integration.ggrc_workflows.generator.WorkflowsGenerator
的用法示例。
在下文中一共展示了WorkflowsGenerator.modify_workflow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBasicWorkflowActions
# 需要导入模块: from integration.ggrc_workflows.generator import WorkflowsGenerator [as 别名]
# 或者: from integration.ggrc_workflows.generator.WorkflowsGenerator import modify_workflow [as 别名]
class TestBasicWorkflowActions(TestCase):
"""
Tests for basic workflow actions
"""
def setUp(self):
super(TestBasicWorkflowActions, self).setUp()
self.api = Api()
self.generator = WorkflowsGenerator()
self.object_generator = ObjectGenerator()
self.random_objects = self.object_generator.generate_random_objects()
self.create_test_cases()
def tearDown(self):
pass
def test_create_workflows(self):
_, wflow = self.generator.generate_workflow(self.one_time_workflow_1)
self.assertIsInstance(wflow, Workflow)
task_groups = db.session.query(TaskGroup)\
.filter(TaskGroup.workflow_id == wflow.id).all()
self.assertEqual(len(task_groups),
len(self.one_time_workflow_1["task_groups"]))
def test_workflows(self):
for workflow in self.all_workflows:
_, wflow = self.generator.generate_workflow(workflow)
self.assertIsInstance(wflow, Workflow)
task_groups = db.session.query(TaskGroup)\
.filter(TaskGroup.workflow_id == wflow.id).all()
self.assertEqual(len(task_groups),
len(workflow["task_groups"]))
def test_activate_wf(self):
for workflow in self.all_workflows:
_, wflow = self.generator.generate_workflow(workflow)
response, wflow = self.generator.activate_workflow(wflow)
self.assert200(response)
def test_one_time_workflow_edits(self):
_, wflow = self.generator.generate_workflow(self.one_time_workflow_1)
wf_dict = {"title": "modified one time wf"}
self.generator.modify_workflow(wflow, data=wf_dict)
modified_wf = db.session.query(Workflow).filter(
Workflow.id == wflow.id).one()
self.assertEqual(wf_dict["title"], modified_wf.title)
def test_one_time_wf_activate(self):
_, wflow = self.generator.generate_workflow(self.one_time_workflow_1)
self.generator.generate_cycle(wflow)
self.generator.activate_workflow(wflow)
tasks = [len(tg.get("task_group_tasks", []))
for tg in self.one_time_workflow_1["task_groups"]]
cycle_tasks = db.session.query(CycleTaskGroupObjectTask).join(
Cycle).join(Workflow).filter(Workflow.id == wflow.id).all()
active_wf = db.session.query(Workflow).filter(
Workflow.id == wflow.id).one()
self.assertEqual(sum(tasks), len(cycle_tasks))
self.assertEqual(active_wf.status, "Active")
def test_one_time_wf_state_transition_dates(self):
_, wflow = self.generator.generate_workflow(self.one_time_workflow_1)
self.generator.generate_cycle(wflow)
self.generator.activate_workflow(wflow)
cycle_tasks = db.session.query(CycleTaskGroupObjectTask).join(
Cycle).join(Workflow).filter(Workflow.id == wflow.id).all()
with freeze_time("2015-6-9 13:00:00"):
today = dtm.datetime.now()
transitions = [
("InProgress", None, None),
("Finished", today, None),
("Declined", None, None),
("Finished", today, None),
("Verified", today, today),
("Finished", today, None),
]
# Iterate over possible transitions and check if dates got set correctly
for (status, expected_finished, expected_verified) in transitions:
cycle_task = cycle_tasks[0]
_, task = self.generator.modify_object(cycle_task, {"status": status})
self.assertEqual(task.finished_date, expected_finished)
self.assertEqual(task.verified_date, expected_verified)
def test_delete_calls(self):
_, workflow = self.generator.generate_workflow()
self.generator.generate_task_group(workflow)
_, task_group = self.generator.generate_task_group(workflow)
task_groups = db.session.query(TaskGroup).filter(
TaskGroup.workflow_id == workflow.id).all()
#.........这里部分代码省略.........