def test_load_playbooks_mixed_files_in_directory(self):
     workflows = [Workflow('something'), Workflow('something2')]
     playbook = Playbook('test', workflows=workflows)
     filepath = os.path.join(test_data_path, 'test.playbook')
     with open(filepath, 'w') as file_out:
         file_out.write(json.dumps(playbook.read()))
     workflows = [Workflow('something'), Workflow('something2')]
     playbook = Playbook('test2', workflows=workflows)
     filepath = os.path.join(test_data_path, 'test2.some_extension')
     with open(filepath, 'w') as file_out:
         file_out.write(json.dumps(playbook.read()))
     loaded = Loader.load_playbooks(test_data_path)
     self.assertEqual(len(loaded), 1)
     self.assertEqual(loaded[0].name, 'test')
 def test_load_multiple_workflows(self):
     workflows = [Workflow('something'), Workflow('something2')]
     playbook = Playbook('test', workflows=workflows)
     filepath = os.path.join(test_data_path, 'test.playbook')
     with open(filepath, 'w') as file_out:
         file_out.write(json.dumps(playbook.read()))
     workflows = [Workflow('something'), Workflow('something2')]
     playbook = Playbook('test2', workflows=workflows)
     filepath = os.path.join(test_data_path, 'test2.playbook')
     with open(filepath, 'w') as file_out:
         file_out.write(json.dumps(playbook.read()))
     loaded = Loader.load_playbooks(test_data_path)
     self.assertEqual(len(loaded), 2)
     self.assertSetEqual({playbook.name for playbook in loaded}, {'test', 'test2'})
 def test_load_playbook(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_playbook(filepath)
     self.assertIsInstance(loaded, Playbook)
     self.assertEqual(loaded.name, 'test')
 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'))