test_yaml_loader.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import os
  2. import unittest
  3. from kalliope.core.ConfigurationManager.YAMLLoader import YAMLFileNotFound, YAMLLoader
  4. class TestYAMLLoader(unittest.TestCase):
  5. """
  6. Class to test YAMLLoader
  7. """
  8. def setUp(self):
  9. pass
  10. def test_get_config(self):
  11. if "/Tests" in os.getcwd():
  12. valid_file_path_to_test = os.getcwd() + os.sep + "brains/brain_test.yml"
  13. else:
  14. valid_file_path_to_test = os.getcwd() + os.sep + "Tests/brains/brain_test.yml"
  15. invalid_file_path = "brains/non_existing_brain.yml"
  16. expected_result = [
  17. {'signals': [{'order': 'test_order'}],
  18. 'neurons': [{'say': {'message': ['test message']}}],
  19. 'name': 'test'},
  20. {'signals': [{'order': 'test_order_2'}],
  21. 'neurons': [{'say': {'message': ['test message']}}],
  22. 'name': 'test2'},
  23. {'signals': [{'order': 'order_for_int'}],
  24. 'neurons': [{'sleep': {'seconds': 60}}],
  25. 'name': 'testint'},
  26. {'includes': ['included_brain_test.yml']},
  27. {'signals': [{'order': 'test_order_3'}],
  28. 'neurons': [{'say': {'message': ['test message']}}],
  29. 'name': 'test3'}
  30. ]
  31. with self.assertRaises(YAMLFileNotFound):
  32. YAMLLoader.get_config(invalid_file_path)
  33. self.assertEqual(YAMLLoader.get_config(valid_file_path_to_test), expected_result)
  34. if __name__ == '__main__':
  35. unittest.main()