コード例 #1
0
 def test_get_all_workflows_as_limited_json(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     workflow_jsons = playbook.get_all_workflows_as_limited_json()
     expected = [{'name': i + 1, 'uid': i} for i in range(3)]
     for workflow_json in workflow_jsons:
         self.assertIn(workflow_json, expected)
コード例 #2
0
 def test_get_all_workflows_as_json(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     workflow_jsons = playbook.get_all_workflow_representations()
     expected = [{'name': i + 1, 'uid': i, 'other': 'other'} for i in range(3)]
     for workflow_json in workflow_jsons:
         self.assertIn(workflow_json, expected)
コード例 #3
0
ファイル: test_playbook.py プロジェクト: xa7YvcR3/WALKOFF
 def test_init_with_workflows(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     self.assertEqual(playbook.name, 'test')
     self.assertEqual(playbook.walkoff_version, walkoff.__version__)
     orderless_list_compare(self, list(playbook.workflows.keys()),
                            [workflow.name for workflow in workflows])
コード例 #4
0
ファイル: test_playbook.py プロジェクト: xa7YvcR3/WALKOFF
 def test_rename_workflow_not_found(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     playbook.rename_workflow('invalid', 'new_name')
     self.assertTrue(all(
         playbook.has_workflow_uid(uid) for uid in range(3)))
     self.assertFalse(playbook.has_workflow_name('invalid'))
コード例 #5
0
 def test_get_workflow_by_uid_no_name(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     self.assertIsNone(playbook.get_workflow_by_uid('invalid'))
コード例 #6
0
 def test_get_workflow_by_uid(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     self.assertEqual(playbook.get_workflow_by_uid('uid'), workflow)
コード例 #7
0
 def test_has_workflow_uid_no_uid(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     self.assertFalse(playbook.has_workflow_uid('invalid'))
コード例 #8
0
 def test_has_workflow_name(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     self.assertTrue(playbook.has_workflow_name('wf_name'))
コード例 #9
0
 def test_add_workflow_name_already_exists(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     playbook.add_workflow(MockWorkflow('uid2', 'wf_name'))
     self.assertEqual(playbook.workflows['wf_name'].uid, 'uid2')
コード例 #10
0
 def test_add_workflow(self):
     workflow = MockWorkflow('uid', 'wf_name')
     playbook = Playbook('test', [workflow])
     playbook.add_workflow(MockWorkflow('uid2', 'test2'))
     orderless_list_compare(self, list(playbook.workflows.keys()), ['wf_name', 'test2'])
コード例 #11
0
 def test_remove_workflow_by_name(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     playbook.remove_workflow_by_name(2)
     self.assertEqual(len(playbook.workflows), 2)
     self.assertFalse(playbook.has_workflow_name(2))
コード例 #12
0
 def test_remove_workflow_by_name_workflow_not_found(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     playbook.remove_workflow_by_name('invalid')
     self.assertEqual(len(playbook.workflows), 3)
コード例 #13
0
 def test_rename_workflow(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     playbook.rename_workflow(3, 'new_name')
     self.assertTrue(playbook.has_workflow_name('new_name'))
     self.assertFalse(playbook.has_workflow_name(3))
コード例 #14
0
 def test_get_all_workflow_uids(self):
     workflows = [MockWorkflow(i, i + 1) for i in range(3)]
     playbook = Playbook('test', workflows)
     orderless_list_compare(self, playbook.get_all_workflow_uids(), list(range(3)))
コード例 #15
0
 def patch_controller_workflows(self, workflow_uids):
     server.running_context.controller.playbook_store.playbooks = {
         i: Playbook(i, [MockWorkflow(workflow_uids[i], i + 1)])
         for i, uid in enumerate(workflow_uids)
     }