test_neuron_module.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import unittest
  2. import mock
  3. from kalliope.core.NeuronModule import NeuronModule
  4. class TestNeuronModule(unittest.TestCase):
  5. def setUp(self):
  6. pass
  7. def tearDown(self):
  8. pass
  9. def test_get_audio_from_stt(self):
  10. """
  11. Test the OrderListener thread is started
  12. """
  13. with mock.patch("kalliope.core.OrderListener.start") as mock_orderListerner_start:
  14. def callback():
  15. pass
  16. NeuronModule.get_audio_from_stt(callback=callback())
  17. mock_orderListerner_start.assert_called_once_with()
  18. mock_orderListerner_start.reset_mock()
  19. def test_update_cache_var(self):
  20. """
  21. Test Update the value of the cache in the provided arg list
  22. """
  23. # True -> False
  24. args_dict = {
  25. "cache": True
  26. }
  27. expected_dict = {
  28. "cache": False
  29. }
  30. self.assertEquals(NeuronModule._update_cache_var(False, args_dict=args_dict),
  31. expected_dict,
  32. "Fail to update the cache value from True to False")
  33. self.assertFalse(args_dict["cache"])
  34. # False -> True
  35. args_dict = {
  36. "cache": False
  37. }
  38. expected_dict = {
  39. "cache": True
  40. }
  41. self.assertEquals(NeuronModule._update_cache_var(True, args_dict=args_dict),
  42. expected_dict,
  43. "Fail to update the cache value from False to True")
  44. self.assertTrue(args_dict["cache"])