def test_load_workflow_file_bad_permissions(self): test_permissions = {'a': 42} filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(json.dumps(test_permissions)) os.chmod(filepath, 0o444) self.assertIsNone(Loader.load_workflow(filepath, 'something'))
def test_load_workflow(self): workflows = [Workflow('something'), Workflow('something2')] playbook = Playbook('test', workflows=workflows) filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(json.dumps(playbook.read())) loaded = Loader.load_workflow(filepath, 'something') self.assertEqual(loaded[0], 'test') self.assertIsInstance(loaded[1], Workflow) self.assertEqual(loaded[1].name, 'something')
def test_load_workflow_invalid_workflow_json(self): workflow_json = { "name": "test_workflow", "start": "start", "actions": [{ "action": "repeatBackToMe", "app": "HelloWorld", "name": "start" }] } playbook_json = {'name': 'test_playbook', 'workflows': [workflow_json]} filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(json.dumps(playbook_json)) self.assertIsNone(Loader.load_workflow(filepath, 'test_workflow'))
def test_load_workflow_with_workflow_not_in_playbook(self): playbook = Playbook('test') filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(json.dumps(playbook.read())) self.assertIsNone(Loader.load_workflow(filepath, 'something'))
def test_load_workflow_name_not_in_playbook_json(self): test_invalid_json = {'a': 42} filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(json.dumps(test_invalid_json)) self.assertIsNone(Loader.load_workflow(filepath, 'something'))
def test_load_workflow_invalid_json_format(self): test_invalid_json = 'something not json' filepath = os.path.join(test_data_path, 'test.json') with open(filepath, 'w') as file_out: file_out.write(test_invalid_json) self.assertIsNone(Loader.load_workflow(filepath, 'something'))
def test_load_workflow_file_dne(self): self.assertIsNone( Loader.load_workflow('/some/invalid/workflow.invalid', 'something'))