Bladeren bron

Merge pull request #321 from kalliope-project/signals_refacto

Signals refacto
Monf 7 jaren geleden
bovenliggende
commit
906581f6b0

+ 0 - 587
Tests/backup_test_order_analyser.py

@@ -1,587 +0,0 @@
-import unittest
-import mock
-
-from kalliope.core.OrderAnalyser import OrderAnalyser
-from kalliope.core.Models.Neuron import Neuron
-from kalliope.core.Models.Synapse import Synapse
-from kalliope.core.Models.Brain import Brain
-from kalliope.core.Models.Settings import Settings
-from kalliope.core.Models.Order import Order
-
-
-class TestOrderAnalyser(unittest.TestCase):
-
-    """Test case for the OrderAnalyser Class"""
-
-    def setUp(self):
-        pass
-
-    def test_start(self):
-        """
-        Testing if the matches from the incoming messages and the signals/order sentences.
-        Scenarii :
-            - Order matchs a synapse and the synapse has been launched.
-            - Order does not match but have a default synapse.
-            - Order does not match and does not have default synapse.
-            - Provide synapse without any external orders
-            - Provide synapse with any external orders
-        """
-        # Init
-        neuron1 = Neuron(name='neurone1', parameters={'var1': 'val1'})
-        neuron2 = Neuron(name='neurone2', parameters={'var2': 'val2'})
-        neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
-        neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
-
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
-
-        synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
-        synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
-        synapse3 = Synapse(name="Synapse3", neurons=[neuron2, neuron4], signals=[signal3])
-
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-        br = Brain(synapses=all_synapse_list)
-
-        with mock.patch("kalliope.core.OrderAnalyser._start_neuron") as mock_start_neuron_method:
-            # assert synapses have been launched
-            order_to_match = "this is the sentence"
-            oa = OrderAnalyser(order=order_to_match,
-                               brain=br)
-            expected_result = [synapse1]
-
-            self.assertEquals(oa.start(),
-                              expected_result,
-                              "Fail to run the expected Synapse matching the order")
-
-            calls = [mock.call(neuron1, {}), mock.call(neuron2, {})]
-            mock_start_neuron_method.assert_has_calls(calls=calls)
-            mock_start_neuron_method.reset_mock()
-
-            # No order matching Default Synapse to run
-            order_to_match = "random sentence"
-            oa = OrderAnalyser(order=order_to_match,
-                               brain=br)
-            oa.settings = mock.MagicMock(default_synapse="Synapse3")
-            expected_result = [synapse3]
-            self.assertEquals(oa.start(),
-                              expected_result,
-                              "Fail to run the default Synapse because no other synapses match the order")
-
-            # No order matching no Default Synapse
-            order_to_match = "random sentence"
-            oa = OrderAnalyser(order=order_to_match,
-                               brain=br)
-            oa.settings = mock.MagicMock()
-            expected_result = []
-            self.assertEquals(oa.start(),
-                              expected_result,
-                              "Fail to no synapse because no synapse matchs and no default defined")
-
-            # Provide synapse to run
-            order_to_match = "this is the sentence"
-            oa = OrderAnalyser(order=order_to_match,
-                               brain=br)
-            expected_result = [synapse1]
-            synapses_to_run = [synapse1]
-
-            self.assertEquals(oa.start(synapses_to_run=synapses_to_run),
-                              expected_result,
-                              "Fail to run the provided synapse to run")
-            calls = [mock.call(neuron1, {}), mock.call(neuron2, {})]
-            mock_start_neuron_method.assert_has_calls(calls=calls)
-            mock_start_neuron_method.reset_mock()
-
-            # Provide synapse and external orders
-            order_to_match = "this is an external sentence"
-            oa = OrderAnalyser(order=order_to_match,
-                               brain=br)
-            external_orders = "this is an external {{ order }}"
-            synapses_to_run = [synapse2]
-            expected_result = [synapse2]
-
-            self.assertEquals(oa.start(synapses_to_run=synapses_to_run, external_order=external_orders),
-                              expected_result,
-                              "Fail to run a provided synapse with external order")
-            calls = [mock.call(neuron3, {"order":u"sentence"}), mock.call(neuron4, {"order":u"sentence"})]
-            mock_start_neuron_method.assert_has_calls(calls=calls)
-            mock_start_neuron_method.reset_mock()
-
-    def test_start_neuron(self):
-        """
-        Testing params association and starting a Neuron
-        """
-
-        neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
-
-        with mock.patch("kalliope.core.NeuronLauncher.NeuronLauncher.start_neuron") as mock_start_neuron_method:
-            # Assert to the neuron is launched
-            neuron1 = Neuron(name='neurone1', parameters={'var1': 'val1'})
-            params = {
-                'param1':'parval1'
-            }
-            OrderAnalyser._start_neuron(neuron=neuron1,params=params)
-            mock_start_neuron_method.assert_called_with(neuron1)
-            mock_start_neuron_method.reset_mock()
-
-            # Assert the params are well passed to the neuron
-            neuron2 = Neuron(name='neurone2', parameters={'var2': 'val2', 'args': ['arg1', 'arg2']})
-            params = {
-                'arg1':'argval1',
-                'arg2':'argval2'
-            }
-            OrderAnalyser._start_neuron(neuron=neuron2, params=params)
-            neuron2_params = Neuron(name='neurone2',
-                                    parameters={'var2': 'val2',
-                                                'args': ['arg1', 'arg2'],
-                                                'arg1':'argval1',
-                                                'arg2':'argval2'}
-                                    )
-            mock_start_neuron_method.assert_called_with(neuron2_params)
-            mock_start_neuron_method.reset_mock()
-
-            # Assert the Neuron is not started when missing args
-            neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3', 'args': ['arg3', 'arg4']})
-            params = {
-                'arg1': 'argval1',
-                'arg2': 'argval2'
-            }
-            OrderAnalyser._start_neuron(neuron=neuron3, params=params)
-            mock_start_neuron_method.assert_not_called()
-            mock_start_neuron_method.reset_mock()
-
-            # Assert no neuron is launched when waiting for args and none are given
-            neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4', 'args': ['arg5', 'arg6']})
-            params = {}
-            OrderAnalyser._start_neuron(neuron=neuron4, params=params)
-            mock_start_neuron_method.assert_not_called()
-            mock_start_neuron_method.reset_mock()
-
-    def test_spelt_order_match_brain_order_via_table(self):
-        order_to_test = "this is the order"
-        sentence_to_test = "this is the order"
-
-        # Success
-        self.assertTrue(OrderAnalyser.spelt_order_match_brain_order_via_table(order_to_test, sentence_to_test),
-                        "Fail matching order with the expected sentence")
-
-        # Failure
-        sentence_to_test = "unexpected sentence"
-        self.assertFalse(OrderAnalyser.spelt_order_match_brain_order_via_table(order_to_test, sentence_to_test),
-                         "Fail to ensure the expected sentence is not matching the order")
-
-        # Upper/lower cases
-        sentence_to_test = "THIS is THE order"
-        self.assertTrue(OrderAnalyser.spelt_order_match_brain_order_via_table(order_to_test, sentence_to_test),
-                        "Fail matching Upper/lower cases")
-
-    def test_format_sentences_to_analyse(self):
-        # First capital in sentence
-        order_to_test = "this is the order"
-        sentence_to_test = "This is the order"
-        expected_result = "this is the order", "this is the order"
-        self.assertEqual(OrderAnalyser._format_sentences_to_analyse(order_to_analyse=order_to_test,
-                                                                    user_said=sentence_to_test),
-                         expected_result,
-                         "Fails formatting the sentences with first capital in sentence")
-
-        # random uppercase in sentence
-        order_to_test = "this is the order"
-        sentence_to_test = "This IS the ordeR"
-        expected_result = "this is the order", "this is the order"
-        self.assertEqual(OrderAnalyser._format_sentences_to_analyse(order_to_analyse=order_to_test,
-                                                                    user_said=sentence_to_test),
-                         expected_result,
-                         "Fails formatting the sentences with random in sentence")
-
-        # random uppercase in order
-        order_to_test = "thiS is THE orDer"
-        sentence_to_test = "this is the order"
-        expected_result = "this is the order", "this is the order"
-        self.assertEqual(OrderAnalyser._format_sentences_to_analyse(order_to_analyse=order_to_test,
-                                                                    user_said=sentence_to_test),
-                         expected_result,
-                         "Fails formatting the sentences with random in order")
-
-        # random uppercase in both order and sentence
-        order_to_test = "thiS is THE orDer"
-        sentence_to_test = "THIS is the Order"
-        expected_result = "this is the order", "this is the order"
-        self.assertEqual(OrderAnalyser._format_sentences_to_analyse(order_to_analyse=order_to_test,
-                                                                    user_said=sentence_to_test),
-                         expected_result,
-                         "Fails formatting the sentences with random in both order and sentence")
-
-    def test_get_split_order_without_bracket(self):
-        # Success
-        order_to_test = "this is the order"
-        expected_result = ["this", "is", "the", "order"]
-        self.assertEqual(OrderAnalyser._get_split_order_without_bracket(order_to_test), expected_result,
-                         "No brackets Fails to return the expected list")
-
-        order_to_test = "this is the {{ order }}"
-        expected_result = ["this", "is", "the"]
-        self.assertEqual(OrderAnalyser._get_split_order_without_bracket(order_to_test), expected_result,
-                         "With spaced brackets Fails to return the expected list")
-
-        order_to_test = "this is the {{order }}"    # left bracket without space
-        expected_result = ["this", "is", "the"]
-        self.assertEqual(OrderAnalyser._get_split_order_without_bracket(order_to_test), expected_result,
-                         "Left brackets Fails to return the expected list")
-
-        order_to_test = "this is the {{ order}}"    # right bracket without space
-        expected_result = ["this", "is", "the"]
-        self.assertEqual(OrderAnalyser._get_split_order_without_bracket(order_to_test), expected_result,
-                         "Right brackets Fails to return the expected list")
-
-        order_to_test = "this is the {{order}}"  # bracket without space
-        expected_result = ["this", "is", "the"]
-        self.assertEqual(OrderAnalyser._get_split_order_without_bracket(order_to_test), expected_result,
-                         "No space brackets Fails to return the expected list")
-
-    def test_associate_order_params_to_values(self):
-        ##
-        # Testing the brackets position behaviour
-        ##
-
-        # Success
-        order_brain = "This is the {{ variable }}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{ variable }} to the 'value'")
-
-        # Success
-        order_brain = "This is the {{variable }}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{variable }} to the 'value'")
-
-        # Success
-        order_brain = "This is the {{ variable}}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{ variable}} to the 'value'")
-
-        # Success
-        order_brain = "This is the {{variable}}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{variable}} to the 'value'")
-
-        # Fail
-        order_brain = "This is the {variable}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertNotEquals(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                             "Should not match the order_brain {variable} to the 'value'")
-
-        # Fail
-        order_brain = "This is the { variable}}"
-        order_user = "This is the value"
-        expected_result = {'variable': 'value'}
-        self.assertNotEquals(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                             "Should not match the order_brain { variable}} to the 'value'")
-
-        ##
-        # Testing the brackets position in the sentence
-        ##
-
-        # Success
-        order_brain = "{{ variable }} This is the"
-        order_user = "value This is the"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{ variable }} in first position "
-                         "ins the sentence to the 'value'")
-
-        # Success
-        order_brain = "This is {{ variable }} the"
-        order_user = " This is value the"
-        expected_result = {'variable': 'value'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{ variable }} in middle position ins "
-                         "the sentence to the 'value'")
-
-        ##
-        # Testing multi variables
-        ##
-
-        # Success
-        order_brain = "This is {{ variable }} the {{ variable2 }}"
-        order_user = "This is value the value2"
-        expected_result = {'variable': 'value',
-                           'variable2': 'value2'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain multi variable to the multi values")
-
-        ##
-        # Testing multi words in variable
-        ##
-
-        # Success
-        order_brain = "This is the {{ variable }}"
-        order_user = "This is the value with multiple words"
-        expected_result = {'variable': 'value with multiple words'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain {{ variable }} to the 'value with multiple words'")
-
-        # Success
-        order_brain = "This is the {{ variable }} and  {{ variable2 }}"
-        order_user = "This is the value with multiple words and second value multiple"
-        expected_result = {'variable': 'value with multiple words',
-                           'variable2': 'second value multiple'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain multiple variables with multiple words as values'")
-
-        ##
-        #  Specific Behaviour
-        ##
-
-        # Upper/Lower case
-        order_brain = "This Is The {{ variable }}"
-        order_user = "ThiS is tHe VAlue"
-        expected_result = {'variable': 'VAlue'}
-        self.assertEqual(OrderAnalyser._associate_order_params_to_values(order_user, order_brain), expected_result,
-                         "Fail to match the order_brain when using Upper/Lower cases")
-
-    def test_get_matching_synapse_list(self):
-        # Init
-        neuron1 = Neuron(name='neurone1', parameters={'var1': 'val1'})
-        neuron2 = Neuron(name='neurone2', parameters={'var2': 'val2'})
-        neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
-        neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
-
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
-
-        synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
-        synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
-        synapse3 = Synapse(name="Synapse3", neurons=[neuron2, neuron4], signals=[signal3])
-
-        order_to_match = "this is the sentence"
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-
-
-        # Success
-        expected_result = synapse1
-        oa_tuple_list = OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
-                                                                   order_to_match=order_to_match)
-        self.assertEquals(oa_tuple_list[0].synapse,
-                          expected_result,
-                          "Fail matching 'the expected synapse' from the complete synapse list and the order")
-
-        # Multiple Matching synapses
-        signal2 = Order(sentence="this is the sentence")
-
-        synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
-        order_to_match = "this is the sentence"
-
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-        expected_result = [synapse1,
-                           synapse2]
-        oa_tuple_list = OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
-                                                                 order_to_match=order_to_match)
-        self.assertEquals(oa_tuple_list[0].synapse,
-                          expected_result[0],
-                          "Fail 'Multiple Matching synapses' from the complete synapse list and the order (first element)")
-        self.assertEquals(oa_tuple_list[1].synapse,
-                          expected_result[1],
-                          "Fail 'Multiple Matching synapses' from the complete synapse list and the order (second element)")
-
-        # matching no synapses
-        order_to_match = "this is not the correct word"
-
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-        expected_result = []
-
-        self.assertEquals(OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
-                                                                   order_to_match=order_to_match),
-                          expected_result,
-                          "Fail matching 'no synapses' from the complete synapse list and the order")
-
-        # matching synapse with all key worlds
-        # /!\ Some words in the order are matching all words in synapses signals !
-        order_to_match = "this is not the correct sentence"
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-        expected_result = [synapse1,
-                           synapse2]
-
-        oa_tuple_list = OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
-                                                                 order_to_match=order_to_match)
-
-        self.assertEquals(oa_tuple_list[0].synapse,
-                          expected_result[0],
-                          "Fail matching 'synapse with all key worlds' from the complete synapse list and the order (first element)")
-        self.assertEquals(oa_tuple_list[1].synapse,
-                          expected_result[1],
-                          "Fail matching 'synapse with all key worlds' from the complete synapse list and the order (second element)")
-
-    def test_get_params_from_order(self):
-
-        string_order = "this is the {{ sentence }}"
-        order_to_check = "this is the value"
-        expected_result = {'sentence': 'value'}
-
-        self.assertEquals(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                          expected_result,
-                          "Fail to retrieve 'the params' of the string_order from the order")
-
-        # Multiple match
-        string_order = "this is the {{ sentence }}"
-
-        order_to_check = "this is the value with multiple words"
-        expected_result = {'sentence': 'value with multiple words'}
-
-        self.assertEqual(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                         expected_result,
-                         "Fail to retrieve the 'multiple words params' of the string_order from the order")
-
-        # Multiple params
-        string_order = "this is the {{ sentence }} with multiple {{ params }}"
-
-        order_to_check = "this is the value with multiple words"
-        expected_result = {'sentence': 'value',
-                            'params':'words'}
-
-        self.assertEqual(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                         expected_result,
-                         "Fail to retrieve the 'multiple params' of the string_order from the order")
-
-        # Multiple params with multiple words
-        string_order = "this is the {{ sentence }} with multiple {{ params }}"
-
-        order_to_check = "this is the multiple values with multiple values as words"
-        expected_result = {'sentence': 'multiple values',
-                           'params': 'values as words'}
-
-        self.assertEqual(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                         expected_result,
-                         "Fail to retrieve the 'multiple params with multiple words' of the string_order from the order")
-
-        # params at the begining of the sentence
-        string_order = "{{ sentence }} this is the sentence"
-
-        order_to_check = "hello world this is the multiple values with multiple values as words"
-        expected_result = {'sentence': 'hello world'}
-
-        self.assertEqual(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                         expected_result,
-                         "Fail to retrieve the 'params at the begining of the sentence' of the string_order from the order")
-
-        # all of the sentence is a variable
-        string_order = "{{ sentence }}"
-
-        order_to_check = "this is the all sentence is a variable"
-        expected_result = {'sentence': 'this is the all sentence is a variable'}
-
-        self.assertEqual(OrderAnalyser._get_params_from_order(string_order=string_order, order_to_check=order_to_check),
-                         expected_result,
-                         "Fail to retrieve the 'all of the sentence is a variable' of the string_order from the order")
-
-    def test_get_default_synapse_from_sysnapses_list(self):
-        # Init
-        neuron1 = Neuron(name='neurone1', parameters={'var1': 'val1'})
-        neuron2 = Neuron(name='neurone2', parameters={'var2': 'val2'})
-        neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
-        neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
-
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
-
-        synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
-        synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
-        synapse3 = Synapse(name="Synapse3", neurons=[neuron2, neuron4], signals=[signal3])
-
-        default_synapse_name = "Synapse2"
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-        expected_result = synapse2
-
-        # Assert equals
-        self.assertEquals(OrderAnalyser._get_default_synapse_from_sysnapses_list(all_synapses_list=all_synapse_list,
-                                                                                 default_synapse_name=default_synapse_name),
-                          expected_result,
-                          "Fail to match the expected default Synapse")
-
-    def test_find_synapse_to_run(self):
-        """
-        Test to find the good synapse to run
-        Scenarii:
-            - 1/ Find the synapse
-            - 2/ No synpase found, no default synapse
-            - 3/ No synapse found, run the default synapse
-        """
-        # Init
-        neuron1 = Neuron(name='neurone1', parameters={'var1': 'val1'})
-        neuron2 = Neuron(name='neurone2', parameters={'var2': 'val2'})
-        neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
-        neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
-
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
-
-        synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
-        synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
-        synapse3 = Synapse(name="Synapse3", neurons=[neuron2, neuron4], signals=[signal3])
-
-        all_synapse_list = [synapse1,
-                            synapse2,
-                            synapse3]
-
-        br = Brain(synapses=all_synapse_list)
-        st = Settings()
-        # 1/ Find synapse
-        order = "this is the sentence"
-        expected_result = synapse1
-        oa_tuple_list = OrderAnalyser._find_synapse_to_run(brain=br,settings=st, order=order)
-        self.assertEquals(oa_tuple_list[0].synapse,
-                          expected_result,
-                          "Fail to run the proper synapse matching the order")
-
-        expected_result = signal1.sentence
-        self.assertEquals(oa_tuple_list[0].order,
-                          expected_result,
-                          "Fail to run the proper synapse matching the order")
-
-        # 2/ No Default synapse
-        order = "No default synapse"
-        expected_result = []
-        self.assertEquals(OrderAnalyser._find_synapse_to_run(brain=br,settings=st, order=order),
-                          expected_result,
-                          "Fail to run no synapse, when no default is defined")
-
-        # 3/ Default synapse
-        st = Settings(default_synapse="Synapse2")
-        order = "default synapse"
-        expected_result = synapse2
-        oa_tuple_list = OrderAnalyser._find_synapse_to_run(brain=br, settings=st, order=order)
-        self.assertEquals(oa_tuple_list[0].synapse,
-                          expected_result,
-                          "Fail to run the default synapse")
-
-
-if __name__ == '__main__':
-    unittest.main()

+ 15 - 32
Tests/test_brain_loader.py

@@ -2,13 +2,11 @@
 import os
 import unittest
 
-from kalliope.core.Models import Singleton
+from kalliope.core.Models import Singleton, Signal
 
 from kalliope.core.ConfigurationManager import BrainLoader
-from kalliope.core.Models import Event
 from kalliope.core.Models import Neuron
 from kalliope.core.Models import Synapse
-from kalliope.core.Models import Order
 from kalliope.core.Models.Brain import Brain
 from kalliope.core.Models.Settings import Settings
 
@@ -57,10 +55,10 @@ class TestBrainLoader(unittest.TestCase):
         neuron = Neuron(name='say', parameters={'message': ['test message']})
         neuron2 = Neuron(name='sleep', parameters={'seconds': 60})
 
-        signal1 = Order(sentence="test_order")
-        signal2 = Order(sentence="test_order_2")
-        signal3 = Order(sentence="test_order_3")
-        signal4 = Order(sentence="order_for_int")
+        signal1 = Signal(name="order", parameters="test_order")
+        signal2 = Signal(name="order", parameters="test_order_2")
+        signal3 = Signal(name="order", parameters="test_order_3")
+        signal4 = Signal(name="order", parameters="order_for_int")
 
         synapse1 = Synapse(name="test", neurons=[neuron], signals=[signal1])
         synapse2 = Synapse(name="test2", neurons=[neuron], signals=[signal2])
@@ -127,28 +125,13 @@ class TestBrainLoader(unittest.TestCase):
     def test_get_signals(self):
         signals = [{'order': 'test_order'}]
 
-        signal = Order(sentence='test_order')
+        signal = Signal(name="order", parameters="test_order")
 
         bl = BrainLoader(file_path=self.brain_to_test)
         signals_from_brain_loader = bl._get_signals(signals)
 
         self.assertEqual([signal], signals_from_brain_loader)
 
-    def test_get_event_or_order_from_dict(self):
-
-        order_object = Order(sentence="test_order")
-        event_object = Event(hour="7")
-
-        dict_order = {'order': 'test_order'}
-        dict_event = {'event': {'hour': '7'}}
-
-        bl = BrainLoader(file_path=self.brain_to_test)
-        order_from_bl = bl._get_event_or_order_from_dict(dict_order)
-        event_from_bl = bl._get_event_or_order_from_dict(dict_event)
-
-        self.assertEqual(order_from_bl, order_object)
-        self.assertEqual(event_from_bl, event_object)
-
     def test_singleton(self):
         bl1 = BrainLoader(file_path=self.brain_to_test)
         bl2 = BrainLoader(file_path=self.brain_to_test)
@@ -184,7 +167,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign a single global variable to parameters")
 
@@ -203,7 +186,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign a global variable with string after to parameters")
 
@@ -222,7 +205,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign global variable with int after to parameters")
 
@@ -241,7 +224,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign multiple global variables to parameters")
 
@@ -260,7 +243,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign a single global when parameter value is a list to neuron")
 
@@ -280,7 +263,7 @@ class TestBrainLoader(unittest.TestCase):
         }
 
         self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
-                                                                settings=st),
+                                                               settings=st),
                          expected_parameters,
                          "Fail to assign a single global when parameter value is a list to neuron")
 
@@ -300,7 +283,7 @@ class TestBrainLoader(unittest.TestCase):
         expected_result = "i am kalliope"
 
         self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
-                                                           settings=st),
+                                                          settings=st),
                          expected_result)
 
         # test with accent
@@ -308,7 +291,7 @@ class TestBrainLoader(unittest.TestCase):
         expected_result = u"i am kalliopé"
 
         self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
-                                                           settings=st),
+                                                          settings=st),
                          expected_result)
 
         # test with int
@@ -316,7 +299,7 @@ class TestBrainLoader(unittest.TestCase):
         expected_result = "i am 1"
 
         self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
-                                                           settings=st),
+                                                          settings=st),
                          expected_result)
 
 

+ 6 - 40
Tests/test_configuration_checker.py

@@ -1,7 +1,7 @@
 import unittest
 
-from kalliope.core.ConfigurationManager.ConfigurationChecker import ConfigurationChecker, NoSynapeName, NoSynapeNeurons, \
-    NoSynapeSignals, NoValidSignal, NoEventPeriod, NoValidOrder, MultipleSameSynapseName
+from kalliope.core.ConfigurationManager.ConfigurationChecker import ConfigurationChecker, NoSynapeName, \
+                                                NoSynapeNeurons, NoSynapeSignals, NoValidSignal, MultipleSameSynapseName
 from kalliope.core.Models import Synapse
 from kalliope.core.Utils.Utils import ModuleNotFoundError
 
@@ -57,48 +57,14 @@ class TestConfigurationChecker(unittest.TestCase):
             ConfigurationChecker.check_neuron_dict(invalid_neuron)
 
     def test_check_signal_dict(self):
-        valid_signal_with_order = {'order': 'test_order'}
-        valid_signal_with_event = {'event': '0 * * * *'}
-        invalid_signal = {'invalid_option': 'test_order'}
+        valid_signal = {'event': {'parameter_1': ['value1']}}
+        invalid_signal = {'non_existing_signal_name': {'parameter_2': ['value2']}}
 
-        self.assertTrue(ConfigurationChecker.check_signal_dict(valid_signal_with_order))
-        self.assertTrue(ConfigurationChecker.check_signal_dict(valid_signal_with_event))
+        self.assertTrue(ConfigurationChecker.check_signal_dict(valid_signal))
 
-        with self.assertRaises(NoValidSignal):
+        with self.assertRaises(ModuleNotFoundError):
             ConfigurationChecker.check_signal_dict(invalid_signal)
 
-    def test_check_event_dict(self):
-        valid_event = {
-            "hour": "18",
-            "minute": "16"
-          }
-        invalid_event = None
-        invalid_event2 = ""
-        invalid_event3 = {
-            "notexisting": "12"
-        }
-
-        self.assertTrue(ConfigurationChecker.check_event_dict(valid_event))
-
-        with self.assertRaises(NoEventPeriod):
-            ConfigurationChecker.check_event_dict(invalid_event)
-        with self.assertRaises(NoEventPeriod):
-            ConfigurationChecker.check_event_dict(invalid_event2)
-        with self.assertRaises(NoEventPeriod):
-            ConfigurationChecker.check_event_dict(invalid_event3)
-
-    def test_check_order_dict(self):
-        valid_order = 'test_order'
-        invalid_order = ''
-        invalid_order2 = None
-
-        self.assertTrue(ConfigurationChecker.check_order_dict(valid_order))
-
-        with self.assertRaises(NoValidOrder):
-            ConfigurationChecker.check_order_dict(invalid_order)
-        with self.assertRaises(NoValidOrder):
-            ConfigurationChecker.check_order_dict(invalid_order2)
-
     def test_check_synapes(self):
         synapse_1 = Synapse(name="test")
         synapse_2 = Synapse(name="test2")

+ 4 - 3
Tests/test_init.py

@@ -43,10 +43,11 @@ class TestInit(unittest.TestCase):
     def test_main(self):
         # test start kalliope
         sys.argv = ['kalliope.py', 'start']
-        with mock.patch('kalliope.core.MainController.__init__') as mock_maincontroller:
-            mock_maincontroller.return_value = None
+        with mock.patch('kalliope.core.SignalLauncher.SignalLauncher.launch_signal_class_by_name') \
+                as mock_signal_launcher:
+            mock_signal_launcher.return_value = None
             main()
-            mock_maincontroller.assert_called()
+            mock_signal_launcher.assert_called()
 
         # test start gui
         sys.argv = ['kalliope.py', 'gui']

+ 17 - 51
Tests/test_models.py

@@ -3,6 +3,7 @@ import ast
 import mock
 
 from kalliope.core.Models.Player import Player
+from kalliope.core.Models.Signal import Signal
 from kalliope.core.Models.Tts import Tts
 
 from kalliope.core.Models.Trigger import Trigger
@@ -16,7 +17,7 @@ from kalliope.core.Models.Dna import Dna
 from kalliope.core import LIFOBuffer
 from kalliope.core.Models.Settings import Settings
 
-from kalliope.core.Models import Neuron, Order, Synapse, Brain, Event, Resources, Singleton
+from kalliope.core.Models import Neuron, Synapse, Brain, Resources, Singleton
 
 from kalliope.core.Models.APIResponse import APIResponse
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
@@ -34,9 +35,9 @@ class TestModels(unittest.TestCase):
         neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
         neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
 
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
+        signal1 = Signal(name="order", parameters="this is the sentence")
+        signal2 = Signal(name="order", parameters="this is the second sentence")
+        signal3 = Signal(name="order", parameters="that is part of the third sentence")
 
         self.synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
         self.synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
@@ -119,35 +120,6 @@ class TestModels(unittest.TestCase):
         self.assertTrue(dna1.__eq__(dna3))
         self.assertFalse(dna1.__eq__(dna2))
 
-    def test_Event(self):
-        event1 = Event(year=2017, month=12, day=31, week=53, day_of_week=2,
-                       hour=8, minute=30, second=0)
-
-        event2 = Event(year=2018, month=11, day=30, week=25, day_of_week=4,
-                       hour=9, minute=40, second=0)
-
-        # same as the event1
-        event3 = Event(year=2017, month=12, day=31, week=53, day_of_week=2,
-                       hour=8, minute=30, second=0)
-
-        expected_result_serialize = {
-            'event': {
-                'week': 53,
-                'second': 0,
-                'minute': 30,
-                'hour': 8,
-                'year': 2017,
-                'day': 31,
-                'day_of_week': 2,
-                'month': 12
-            }
-        }
-
-        self.assertDictEqual(expected_result_serialize, event1.serialize())
-
-        self.assertTrue(event1.__eq__(event3))
-        self.assertFalse(event1.__eq__(event2))
-
     def test_MatchedSynapse(self):
         user_order = "user order"
         matched_synapse1 = MatchedSynapse(matched_synapse=self.synapse1, matched_order=user_order)
@@ -215,20 +187,6 @@ class TestModels(unittest.TestCase):
 
         self.assertDictEqual(ast.literal_eval(neuron.__str__()), ast.literal_eval(expected_result_str))
 
-    def test_Order(self):
-        order1 = Order(sentence="this is an order")
-        order2 = Order(sentence="this is an other order")
-        order3 = Order(sentence="this is an order")
-
-        expected_result_serialize = {'order': 'this is an order'}
-        expected_result_str = "{'order': 'this is an order'}"
-
-        self.assertEqual(expected_result_serialize, order1.serialize())
-        self.assertEqual(expected_result_str, order1.__str__())
-
-        self.assertTrue(order1.__eq__(order3))
-        self.assertFalse(order1.__eq__(order2))
-
     def test_Resources(self):
         resource1 = Resources(neuron_folder="/path/neuron", stt_folder="/path/stt",
                               tts_folder="/path/tts", trigger_folder="/path/trigger")
@@ -398,8 +356,8 @@ class TestModels(unittest.TestCase):
         neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
         neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
 
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
+        signal1 = Signal(name="order", parameters="this is the sentence")
+        signal2 = Signal(name="order", parameters="this is the second sentence")
 
         synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
         synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])
@@ -408,13 +366,14 @@ class TestModels(unittest.TestCase):
         expected_result_serialize = {
             'signals': [
                 {
-                    'order': 'this is the sentence'
+                    'name': 'order',
+                    'parameters': 'this is the sentence'
                 }
             ],
             'neurons': [
                 {
                     'name': 'neurone1',
-                     'parameters': {
+                    'parameters': {
                          'var1': 'val1'
                      }
                 },
@@ -471,3 +430,10 @@ class TestModels(unittest.TestCase):
         self.assertFalse(tts1.__eq__(tts2))
 
 
+if __name__ == '__main__':
+    unittest.main()
+
+    # suite = unittest.TestSuite()
+    # suite.addTest(TestLIFOBuffer("test_process_neuron_list"))
+    # runner = unittest.TextTestRunner()
+    # runner.run(suite)

+ 4 - 4
Tests/test_order_analyser.py

@@ -3,9 +3,9 @@ import unittest
 
 from kalliope.core.Models import Brain
 from kalliope.core.Models import Neuron
-from kalliope.core.Models import Order
 from kalliope.core.Models import Synapse
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
+from kalliope.core.Models.Signal import Signal
 from kalliope.core.OrderAnalyser import OrderAnalyser
 
 
@@ -23,9 +23,9 @@ class TestOrderAnalyser(unittest.TestCase):
         neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
         neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
 
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
+        signal1 = Signal(name="order", parameters="this is the sentence")
+        signal2 = Signal(name="order", parameters="this is the second sentence")
+        signal3 = Signal(name="order", parameters="that is part of the third sentence")
 
         synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
         synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])

+ 98 - 64
Tests/test_rest_api.py

@@ -73,51 +73,84 @@ class TestRestAPI(LiveServerTestCase):
 
         response = self.client.get(url)
         expected_content = {
-            "synapses": [{
-                "name": "test",
-                "neurons": [{
-                    "name": "say",
-                    "parameters": {
-                        "message": ["test message"]
-                    }
-                }],
-                "signals": [{
-                    "order": "test_order"
-                }]
-            }, {
-                "name": "test2",
-                "neurons": [{
-                    "name": "say",
-                    "parameters": {
-                        "message": ["test message"]
-                    }
-                }],
-                "signals": [{
-                    "order": "bonjour"
-                }]
-            }, {
-                "name": "test4",
-                "neurons": [{
-                    "name": "say",
-                    "parameters": {
-                        "message": ["test message {{parameter1}}"]
-                    }
-                }],
-                "signals": [{
-                    "order": "test_order_with_parameter"
-                }]
-            }, {
-                "name": "test3",
-                "neurons": [{
-                    "name": "say",
-                    "parameters": {
-                        "message": ["test message"]
-                    }
-                }],
-                "signals": [{
-                    "order": "test_order_3"
-                }]
-            }]
+          "synapses": [
+            {
+              "name": "test",
+              "neurons": [
+                {
+                  "name": "say",
+                  "parameters": {
+                    "message": [
+                      "test message"
+                    ]
+                  }
+                }
+              ],
+              "signals": [
+                {
+                  "name": "order",
+                  "parameters": "test_order"
+                }
+              ]
+            },
+            {
+              "name": "test2",
+              "neurons": [
+                {
+                  "name": "say",
+                  "parameters": {
+                    "message": [
+                      "test message"
+                    ]
+                  }
+                }
+              ],
+              "signals": [
+                {
+                  "name": "order",
+                  "parameters": "bonjour"
+                }
+              ]
+            },
+            {
+              "name": "test4",
+              "neurons": [
+                {
+                  "name": "say",
+                  "parameters": {
+                    "message": [
+                      "test message {{parameter1}}"
+                    ]
+                  }
+                }
+              ],
+              "signals": [
+                {
+                  "name": "order",
+                  "parameters": "test_order_with_parameter"
+                }
+              ]
+            },
+            {
+              "name": "test3",
+              "neurons": [
+                {
+                  "name": "say",
+                  "parameters": {
+                    "message": [
+                      "test message"
+                    ]
+                  }
+                }
+              ],
+              "signals": [
+                {
+                  "name": "order",
+                  "parameters": "test_order_3"
+                }
+              ]
+            }
+          ]
         }
         # a lot of char ti process
         self.maxDiff = None
@@ -129,25 +162,26 @@ class TestRestAPI(LiveServerTestCase):
         url = self.get_server_url() + "/synapses/test"
         response = self.client.get(url)
 
-        expected_content = {
-            "synapses": {
-                "name": "test",
-                "neurons": [
-                    {
-                        "name": "say",
-                        "parameters": {
-                            "message": [
-                                "test message"
-                            ]
-                        }
-                    }
-                ],
-                "signals": [
-                    {
-                        "order": "test_order"
-                    }
-                ]
-            }
+        expected_content ={
+          "synapses": {
+            "name": "test",
+            "neurons": [
+              {
+                "name": "say",
+                "parameters": {
+                  "message": [
+                    "test message"
+                  ]
+                }
+              }
+            ],
+            "signals": [
+              {
+                "name": "order",
+                "parameters": "test_order"
+              }
+            ]
+          }
         }
         self.assertEqual(json.dumps(expected_content, sort_keys=True),
                          json.dumps(json.loads(response.get_data().decode('utf-8')), sort_keys=True))

+ 4 - 5
Tests/test_synapse_launcher.py

@@ -3,13 +3,12 @@ import unittest
 import mock
 
 from kalliope.core import LIFOBuffer
-from kalliope.core.Models import Brain
+from kalliope.core.Models import Brain, Signal
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
 from kalliope.core.Models.Settings import Settings
 from kalliope.core.SynapseLauncher import SynapseLauncher, SynapseNameNotFound
 
 from kalliope.core.Models import Neuron
-from kalliope.core.Models import Order
 from kalliope.core.Models import Synapse
 
 
@@ -25,9 +24,9 @@ class TestSynapseLauncher(unittest.TestCase):
         neuron3 = Neuron(name='neurone3', parameters={'var3': 'val3'})
         neuron4 = Neuron(name='neurone4', parameters={'var4': 'val4'})
 
-        signal1 = Order(sentence="this is the sentence")
-        signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="that is part of the third sentence")
+        signal1 = Signal(name="order", parameters="this is the sentence")
+        signal2 = Signal(name="order", parameters="this is the second sentence")
+        signal3 = Signal(name="order", parameters="that is part of the third sentence")
 
         self.synapse1 = Synapse(name="Synapse1", neurons=[neuron1, neuron2], signals=[signal1])
         self.synapse2 = Synapse(name="Synapse2", neurons=[neuron3, neuron4], signals=[signal2])

+ 54 - 8
kalliope/__init__.py

@@ -7,9 +7,10 @@ from kalliope.core import ShellGui
 from kalliope.core import Utils
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager.BrainLoader import BrainLoader
-from kalliope.core.EventManager import EventManager
-from kalliope.core.MainController import MainController
+from kalliope.core.SignalLauncher import SignalLauncher
 from kalliope.core.Utils.RpiUtils import RpiUtils
+from flask import Flask
+from kalliope.core.RestAPI.FlaskAPI import FlaskAPI
 
 from ._version import version_str
 import signal
@@ -144,17 +145,26 @@ def main():
                                                             is_api_call=False)
 
         if (parser.run_synapse is None) and (parser.run_order is None):
-            # first, load events in event manager
-            EventManager(brain.synapses)
-            Utils.print_success("Events loaded")
-            # then start kalliope
+            # start kalliope
             Utils.print_success("Starting Kalliope")
             Utils.print_info("Press Ctrl+C for stopping")
             # catch signal for killing on Ctrl+C pressed
             signal.signal(signal.SIGINT, signal_handler)
-            # start the state machine
+
+            # get a list of signal class to load from declared synapse in the brain
+            # this list will contain string of signal class type.
+            # For example, if the brain contains multiple time the signal type "order", the list will be ["order"]
+            # If the brain contains some synapse with "order" and "event", the list will be ["order", "event"]
+            list_signals_class_to_load = get_list_signal_class_to_load(brain)
+            # start each class name
             try:
-                MainController(brain=brain)
+                for signal_class_name in list_signals_class_to_load:
+                    signal_instance = SignalLauncher.launch_signal_class_by_name(signal_name=signal_class_name,
+                                                                                 brain=brain,
+                                                                                 settings=settings)
+                    if signal_instance is not None:
+                        signal_instance.start()
+
             except (KeyboardInterrupt, SystemExit):
                 Utils.print_info("Ctrl+C pressed. Killing Kalliope")
             finally:
@@ -164,6 +174,9 @@ def main():
                     import RPi.GPIO as GPIO
                     GPIO.cleanup()
 
+            # start rest api
+            start_rest_api(settings, brain)
+
     if parser.action == "gui":
         try:
             ShellGui(brain=brain)
@@ -195,3 +208,36 @@ def configure_logging(debug=None):
         logger.setLevel(logging.INFO)
 
     logger.debug("Logger ready")
+
+
+def get_list_signal_class_to_load(brain):
+    """
+    Return a list of signal class name
+    For all synapse, each signal type is added to a list only if the signal is not yet present in the list
+    :param brain: Brain object
+    :type brain: Brain
+    :return: set of signal class
+    """
+    list_signal_class_name = set()
+
+    for synapse in brain.synapses:
+        for signal_object in synapse.signals:
+            list_signal_class_name.add(signal_object.name)
+    logger.debug("[Kalliope entrypoint] List of signal class to load: %s" % list_signal_class_name)
+    return list_signal_class_name
+
+
+def start_rest_api(settings, brain):
+    """
+    Start the Rest API if asked in the user settings
+    """
+    # run the api if the user want it
+    if settings.rest_api.active:
+        Utils.print_info("Starting REST API Listening port: %s" % settings.rest_api.port)
+        app = Flask(__name__)
+        flask_api = FlaskAPI(app=app,
+                             port=settings.rest_api.port,
+                             brain=brain,
+                             allowed_cors_origin=settings.rest_api.allowed_cors_origin)
+        flask_api.daemon = True
+        flask_api.start()

+ 4 - 51
kalliope/core/ConfigurationManager/BrainLoader.py

@@ -4,15 +4,14 @@ import os
 from six import with_metaclass
 import six
 
+from kalliope.core.Models.Signal import Signal
 from .YAMLLoader import YAMLLoader
 from kalliope.core.Utils import Utils
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager.ConfigurationChecker import ConfigurationChecker
 from kalliope.core.Models import Singleton
 from kalliope.core.Models.Brain import Brain
-from kalliope.core.Models.Event import Event
 from kalliope.core.Models.Neuron import Neuron
-from kalliope.core.Models.Order import Order
 from kalliope.core.Models.Synapse import Synapse
 
 logging.basicConfig()
@@ -166,38 +165,12 @@ class BrainLoader(with_metaclass(Singleton, object)):
         signals = list()
         for signal_dict in signals_dict:
             if ConfigurationChecker().check_signal_dict(signal_dict):
-                event_or_order = cls._get_event_or_order_from_dict(signal_dict)
-                signals.append(event_or_order)
+                for signal_name in signal_dict:
+                    new_signal = Signal(name=signal_name, parameters=signal_dict[signal_name])
+                    signals.append(new_signal)
 
         return signals
 
-    @classmethod
-    def _get_event_or_order_from_dict(cls, signal_or_event_dict):
-        """
-        The signal is either an Event or an Order
-
-        :param signal_or_event_dict: A dict of event or signal
-        :type signal_or_event_dict: dict
-        :return: The object corresponding to An Order or an Event
-        :rtype: An Order or an Event
-
-        :Example:
-
-            event_or_order = cls._get_event_or_order_from_dict(signal_dict)
-
-        .. seealso:: Event, Order
-        .. warnings:: Static method and Private
-        """
-        if 'event' in signal_or_event_dict:
-            event = signal_or_event_dict["event"]
-            if ConfigurationChecker.check_event_dict(event):
-                return cls._get_event_object(event)
-
-        if 'order' in signal_or_event_dict:
-            order = signal_or_event_dict["order"]
-            if ConfigurationChecker.check_order_dict(order):
-                return Order(sentence=order)
-
     @staticmethod
     def _get_root_brain_path():
         """
@@ -221,26 +194,6 @@ class BrainLoader(with_metaclass(Singleton, object)):
             return brain_path
         raise IOError("Default brain.yml file not found")
 
-    @classmethod
-    def _get_event_object(cls, event_dict):
-        def get_key(key_name):
-            try:
-                return event_dict[key_name]
-            except KeyError:
-                return None
-
-        year = get_key("year")
-        month = get_key("month")
-        day = get_key("day")
-        week = get_key("week")
-        day_of_week = get_key("day_of_week")
-        hour = get_key("hour")
-        minute = get_key("minute")
-        second = get_key("second")
-
-        return Event(year=year, month=month, day=day, week=week,
-                     day_of_week=day_of_week, hour=hour, minute=minute, second=second)
-
     @classmethod
     def _replace_global_variables(cls, parameter, settings):
         """

+ 34 - 71
kalliope/core/ConfigurationManager/ConfigurationChecker.py

@@ -5,6 +5,7 @@ import imp
 from kalliope.core.Utils.Utils import ModuleNotFoundError
 from kalliope.core.ConfigurationManager.SettingLoader import SettingLoader
 
+
 class InvalidSynapeName(Exception):
     """
     The name of the synapse is not correct. It should only contains alphanumerics at the beginning and the end of
@@ -48,15 +49,6 @@ class NoValidSignal(Exception):
     pass
 
 
-class NoEventPeriod(Exception):
-    """
-    An Event must contains a period corresponding to its execution
-
-    .. seealso:: Event
-    """
-    pass
-
-
 class MultipleSameSynapseName(Exception):
     """
     A synapse name must be unique
@@ -172,72 +164,43 @@ class ConfigurationChecker:
 
     @staticmethod
     def check_signal_dict(signal_dict):
-        """
-        Check received signal dictionary is valid:
-
-        :param signal_dict: The signal Dictionary
-        :type signal_dict: Dict
-        :return: True if signal are ok
-        :rtype: Boolean
-
-        :Example:
-
-            ConfigurationChecker().check_signal_dict(signal_dict):
-
-        .. seealso:: Order, Event
-        .. raises:: NoValidSignal
-        .. warnings:: Static and Public
-        """
-
-        if ('event' not in signal_dict) and ('order' not in signal_dict):
-            raise NoValidSignal("The signal is not an event or an order %s" % signal_dict)
-        return True
-
-    @staticmethod
-    def check_event_dict(event_dict):
-        """
-        Check received event dictionary is valid:
-
-        :param event_dict: The event Dictionary
-        :type event_dict: Dict
-        :return: True if event are ok
-        :rtype: Boolean
-
-        :Example:
 
-            ConfigurationChecker().check_event_dict(event_dict):
+        def check_signal_exist(signal_name):
+            """
+            Return True if the signal_name python Class exist in signals package
+            :param signal_name: Name of the neuron module to check
+            :type signal_name: str
+            :return:
+            """
+            sl = SettingLoader()
+            settings = sl.settings
+            package_name = "kalliope.signals" + "." + signal_name.lower() + "." + signal_name.lower()
+            if settings.resources is not None:
+                neuron_resource_path = settings.resources.neuron_folder + \
+                                       os.sep + signal_name.lower() + os.sep + \
+                                       signal_name.lower() + ".py"
+                if os.path.exists(neuron_resource_path):
+                    imp.load_source(signal_name.capitalize(), neuron_resource_path)
+                    package_name = signal_name.capitalize()
 
-        .. seealso::  Event
-        .. raises:: NoEventPeriod
-        .. warnings:: Static and Public
-        """
-        def get_key(key_name):
             try:
-                return event_dict[key_name]
-            except KeyError:
-                return None
-
-        if event_dict is None or event_dict == "":
-            raise NoEventPeriod("Event must contain at least one of those elements: "
-                                "year, month, day, week, day_of_week, hour, minute, second")
-
-        # check content as at least on key
-        year = get_key("year")
-        month = get_key("month")
-        day = get_key("day")
-        week = get_key("week")
-        day_of_week = get_key("day_of_week")
-        hour = get_key("hour")
-        minute = get_key("minute")
-        second = get_key("second")
-
-        list_to_check = [year, month, day, week, day_of_week, hour, minute, second]
-        number_of_none_object = list_to_check.count(None)
-        list_size = len(list_to_check)
-        if number_of_none_object >= list_size:
-            raise NoEventPeriod("Event must contain at least one of those elements: "
-                                "year, month, day, week, day_of_week, hour, minute, second")
+                mod = __import__(package_name, fromlist=[signal_name.capitalize()])
+                getattr(mod, signal_name.capitalize())
+            except AttributeError:
+                raise ModuleNotFoundError(
+                    "[AttributeError] The module %s does not exist in the package %s " % (signal_name.capitalize(),
+                                                                                          package_name))
+            except ImportError:
+                raise ModuleNotFoundError(
+                    "[ImportError] The module %s does not exist in the package %s " % (signal_name.capitalize(),
+                                                                                       package_name))
+            return True
 
+        if isinstance(signal_dict, dict):
+            for signal_name in signal_dict:
+                check_signal_exist(signal_name)
+        else:
+            check_signal_exist(signal_dict)
         return True
 
     @staticmethod

+ 0 - 49
kalliope/core/EventManager.py

@@ -1,49 +0,0 @@
-from apscheduler.schedulers.background import BackgroundScheduler
-from apscheduler.triggers.cron import CronTrigger
-
-from kalliope.core.ConfigurationManager import BrainLoader
-from kalliope.core.SynapseLauncher import SynapseLauncher
-from kalliope.core import Utils
-from kalliope.core.Models import Event
-
-
-class EventManager(object):
-
-    def __init__(self, synapses):
-        Utils.print_info('Starting event manager')
-        self.scheduler = BackgroundScheduler()
-        self.synapses = synapses
-        self.load_events()
-        self.scheduler.start()
-
-    def load_events(self):
-        """
-        For each received synapse that have an event as signal, we add a new job scheduled
-        to launch the synapse
-        :return:
-        """
-        for synapse in self.synapses:
-            for signal in synapse.signals:
-                # if the signal is an event we add it to the task list
-                if type(signal) == Event:
-                    my_cron = CronTrigger(year=signal.year,
-                                          month=signal.month,
-                                          day=signal.day,
-                                          week=signal.week,
-                                          day_of_week=signal.day_of_week,
-                                          hour=signal.hour,
-                                          minute=signal.minute,
-                                          second=signal.second)
-                    Utils.print_info("Add synapse name \"%s\" to the scheduler: %s" % (synapse.name, my_cron))
-                    self.scheduler.add_job(self.run_synapse_by_name, my_cron, args=[synapse.name])
-
-    @staticmethod
-    def run_synapse_by_name(synapse_name):
-        """
-        This method will run the synapse
-        """
-        Utils.print_info("Event triggered, running synapse: %s" % synapse_name)
-        # get a brain
-        brain_loader = BrainLoader()
-        brain = brain_loader.brain
-        SynapseLauncher.start_synapse_by_name(synapse_name, brain=brain)

+ 0 - 49
kalliope/core/Models/Event.py

@@ -1,49 +0,0 @@
-class Event(object):
-    """
-    This Class is representing an Event which is raised by when the System at some defined time.
-
-    .. note:: Events are based on the system crontab
-    """
-
-    def __init__(self, year=None, month=None, day=None, week=None, day_of_week=None,
-                 hour=None, minute=None, second=None):
-        self.year = year
-        self.month = month
-        self.day = day
-        self.week = week
-        self.day_of_week = day_of_week
-        self.hour = hour
-        self.minute = minute
-        self.second = second
-
-    def __str__(self):
-        return str(self.serialize())
-
-    def serialize(self):
-        """
-        This method allows to serialize in a proper way this object
-
-        :return: A dict of name / period
-        :rtype: Dict
-        """
-
-        return {
-            'event': {
-                "year": self.year,
-                "month": self.month,
-                "day": self.day,
-                "week": self.week,
-                "day_of_week": self.day_of_week,
-                "hour": self.hour,
-                "minute": self.minute,
-                "second": self.second,
-            }
-        }
-
-    def __eq__(self, other):
-        """
-        This is used to compare 2 objects
-        :param other:
-        :return:
-        """
-        return self.__dict__ == other.__dict__

+ 0 - 32
kalliope/core/Models/Order.py

@@ -1,32 +0,0 @@
-class Order(object):
-    """
-    This Class is representing an Order which is raised by when an entry (Vocal/REST/ anything ...) is matching it.
-
-    .. note:: Order are defined in the brain file for each synapse.
-    """
-
-    def __init__(self, sentence):
-        self.sentence = sentence
-
-    def __str__(self):
-        return str(self.serialize())
-
-    def serialize(self):
-        """
-        This method allows to serialize in a proper way this object
-
-        :return: A dict of order
-        :rtype: Dict
-        """
-
-        return {
-            'order': self.sentence
-        }
-
-    def __eq__(self, other):
-        """
-        This is used to compare 2 objects
-        :param other:
-        :return:
-        """
-        return self.__dict__ == other.__dict__

+ 51 - 0
kalliope/core/Models/Signal.py

@@ -0,0 +1,51 @@
+class Signal(object):
+    """
+    This Class is representing a Signal which is corresponding to an input action that should start executing neuron
+    list when triggered
+    """
+
+    def __init__(self, name=None, parameters=None):
+        self.name = name
+        self.parameters = parameters
+
+    def serialize(self):
+        """
+        This method allows to serialize in a proper way this object
+
+        :return: A dict of name and parameters
+        :rtype: Dict
+        """
+        return {
+            'name': self.name,
+            'parameters': self.parameters
+        }
+
+    def __str__(self):
+        """
+        Return a string that describe the signal. If a parameter contains the word "password",
+        the output of this parameter will be masked in order to not appears in clean in the console
+        :return: string description of the neuron
+        """
+        returned_dict = {
+            'name': self.name,
+            'parameters': self.parameters
+        }
+
+        cleaned_parameters = dict()
+        if isinstance(self.parameters, dict):
+            for key, value in self.parameters.items():
+                if "password" in key:
+                    cleaned_parameters[key] = "*****"
+                else:
+                    cleaned_parameters[key] = value
+            returned_dict["parameters"] = cleaned_parameters
+
+        return str(returned_dict)
+
+    def __eq__(self, other):
+        """
+        This is used to compare 2 objects
+        :param other:
+        :return:
+        """
+        return self.__dict__ == other.__dict__

+ 1 - 2
kalliope/core/Models/__init__.py

@@ -1,8 +1,7 @@
 from .Singleton import Singleton
-from .Event import Event
 from .Resources import Resources
 from .Brain import Brain
-from .Order import Order
 from .Synapse import Synapse
 from .Neuron import Neuron
 from .RpiSettings import RpiSettings
+from .Signal import Signal

+ 4 - 5
kalliope/core/OrderAnalyser.py

@@ -1,13 +1,11 @@
 # coding: utf8
 import collections
 from collections import Counter
-import sys
 import six
 
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
 from kalliope.core.Utils.Utils import Utils
 from kalliope.core.ConfigurationManager import SettingLoader
-from kalliope.core.Models import Order
 
 import logging
 
@@ -54,12 +52,13 @@ class OrderAnalyser:
         for synapse in cls.brain.synapses:
             # we are only concerned by synapse with a order type of signal
             for signal in synapse.signals:
-                if type(signal) == Order:
-                    if cls.spelt_order_match_brain_order_via_table(signal.sentence, order):
+
+                if signal.name == "order":
+                    if cls.spelt_order_match_brain_order_via_table(signal.parameters, order):
                         # the order match the synapse, we add it to the returned list
                         logger.debug("Order found! Run synapse name: %s" % synapse.name)
                         Utils.print_success("Order matched in the brain. Running synapse \"%s\"" % synapse.name)
-                        list_match_synapse.append(synapse_order_tuple(synapse=synapse, order=signal.sentence))
+                        list_match_synapse.append(synapse_order_tuple(synapse=synapse, order=signal.parameters))
 
         # create a list of MatchedSynapse from the tuple list
         list_synapse_to_process = list()

+ 28 - 0
kalliope/core/SignalLauncher.py

@@ -0,0 +1,28 @@
+import logging
+
+from kalliope import Utils
+
+logging.basicConfig()
+logger = logging.getLogger("kalliope")
+
+
+class SignalLauncher:
+
+    def __init__(self):
+        pass
+
+    @classmethod
+    def launch_signal_class_by_name(cls, signal_name, brain=None, settings=None):
+        """
+        load the signal class from the given name, pass the brain and settings to the signal
+        :param signal_name: name of the signal class to load
+        :param brain: Brain Object
+        :param settings: Settings Object
+        """
+        signal_folder = None
+        if settings.resources:
+            signal_folder = settings.resources.signal_folder
+
+        return Utils.get_dynamic_class_instantiation(package_name="signals",
+                                                     module_name=signal_name,
+                                                     resources_dir=signal_folder)

+ 0 - 2
kalliope/core/__init__.py

@@ -10,5 +10,3 @@ from kalliope.core.LIFOBuffer import LIFOBuffer
 from kalliope.core.NeuronParameterLoader import NeuronParameterLoader
 from kalliope.core.NeuronModule import NeuronModule
 from kalliope.core.PlayerModule import PlayerModule
-from kalliope.core.MainController import MainController
-from kalliope.core.EventManager import EventManager

+ 0 - 0
kalliope/signals/__init__.py


+ 1 - 0
kalliope/signals/event/__init__.py

@@ -0,0 +1 @@
+from .event import Event

+ 116 - 0
kalliope/signals/event/event.py

@@ -0,0 +1,116 @@
+from threading import Thread
+
+from apscheduler.schedulers.background import BackgroundScheduler
+from apscheduler.triggers.cron import CronTrigger
+
+from kalliope.core.ConfigurationManager import BrainLoader
+from kalliope.core.SynapseLauncher import SynapseLauncher
+from kalliope.core import Utils
+
+
+class NoEventPeriod(Exception):
+    """
+    An Event must contains a period corresponding to its execution
+
+    .. seealso:: Event
+    """
+    pass
+
+
+class Event(Thread):
+    def __init__(self):
+        super(Event, self).__init__()
+        Utils.print_info('Starting event manager')
+        self.scheduler = BackgroundScheduler()
+        self.brain = BrainLoader().get_brain()
+        self.synapses = self.brain.synapses
+        self.load_events()
+
+    def run(self):
+        self.scheduler.start()
+
+    def load_events(self):
+        """
+        For each received synapse that have an event as signal, we add a new job scheduled
+        to launch the synapse
+        :return:
+        """
+        for synapse in self.synapses:
+            for signal in synapse.signals:
+                # if the signal is an event we add it to the task list
+                if signal.name == "event":
+                    if self.check_event_dict(signal.parameters):
+                        my_cron = CronTrigger(year=self.get_parameter_from_dict("year", signal.parameters),
+                                              month=self.get_parameter_from_dict("month", signal.parameters),
+                                              day=self.get_parameter_from_dict("day", signal.parameters),
+                                              week=self.get_parameter_from_dict("week", signal.parameters),
+                                              day_of_week=self.get_parameter_from_dict("day_of_week", signal.parameters),
+                                              hour=self.get_parameter_from_dict("hour", signal.parameters),
+                                              minute=self.get_parameter_from_dict("minute", signal.parameters),
+                                              second=self.get_parameter_from_dict("second", signal.parameters),)
+                        Utils.print_info("Add synapse name \"%s\" to the scheduler: %s" % (synapse.name, my_cron))
+                        self.scheduler.add_job(self.run_synapse_by_name, my_cron, args=[synapse.name])
+
+    @staticmethod
+    def run_synapse_by_name(synapse_name):
+        """
+        This method will run the synapse
+        """
+        Utils.print_info("Event triggered, running synapse: %s" % synapse_name)
+        # get a brain
+        brain_loader = BrainLoader()
+        brain = brain_loader.brain
+        SynapseLauncher.start_synapse_by_name(synapse_name, brain=brain)
+
+    @staticmethod
+    def get_parameter_from_dict(parameter_name, parameters_dict):
+        """
+        return the value in the dict parameters_dict frm the key parameter_name
+        return None if the key does not exist
+        :param parameter_name: name of the key
+        :param parameters_dict: dict
+        :return: string
+        """
+        try:
+            return parameters_dict[parameter_name]
+        except KeyError:
+            return None
+
+    @staticmethod
+    def check_event_dict(event_dict):
+        """
+        Check received event dictionary of parameter is valid:
+
+        :param event_dict: The event Dictionary
+        :type event_dict: Dict
+        :return: True if event are ok
+        :rtype: Boolean
+        """
+        def get_key(key_name):
+            try:
+                return event_dict[key_name]
+            except KeyError:
+                return None
+
+        if event_dict is None or event_dict == "":
+            raise NoEventPeriod("Event must contain at least one of those elements: "
+                                "year, month, day, week, day_of_week, hour, minute, second")
+
+        # check content as at least on key
+        year = get_key("year")
+        month = get_key("month")
+        day = get_key("day")
+        week = get_key("week")
+        day_of_week = get_key("day_of_week")
+        hour = get_key("hour")
+        minute = get_key("minute")
+        second = get_key("second")
+
+        list_to_check = [year, month, day, week, day_of_week, hour, minute, second]
+        number_of_none_object = list_to_check.count(None)
+        list_size = len(list_to_check)
+        if number_of_none_object >= list_size:
+            raise NoEventPeriod("Event must contain at least one of those elements: "
+                                "year, month, day, week, day_of_week, hour, minute, second")
+
+        return True

+ 0 - 0
kalliope/signals/event/tests/__init__.py


+ 20 - 0
kalliope/signals/event/tests/test_event.py

@@ -0,0 +1,20 @@
+#
+# def test_check_event_dict(self):
+#     valid_event = {
+#         "hour": "18",
+#         "minute": "16"
+#     }
+#     invalid_event = None
+#     invalid_event2 = ""
+#     invalid_event3 = {
+#         "notexisting": "12"
+#     }
+#
+#     self.assertTrue(ConfigurationChecker.check_event_dict(valid_event))
+#
+#     with self.assertRaises(NoEventPeriod):
+#         ConfigurationChecker.check_event_dict(invalid_event)
+#     with self.assertRaises(NoEventPeriod):
+#         ConfigurationChecker.check_event_dict(invalid_event2)
+#     with self.assertRaises(NoEventPeriod):
+#         ConfigurationChecker.check_event_dict(invalid_event3)

+ 1 - 0
kalliope/signals/order/__init__.py

@@ -0,0 +1 @@
+from .order import Order

+ 33 - 51
kalliope/core/MainController.py → kalliope/signals/order/order.py

@@ -1,33 +1,29 @@
 import logging
 import random
+from threading import Thread
 from time import sleep
 
-from transitions import Machine
-from kalliope.core import Utils
-from kalliope.core.ConfigurationManager import SettingLoader
+from kalliope.core.Utils.RpiUtils import RpiUtils
+
+from kalliope.core.SynapseLauncher import SynapseLauncher
+
 from kalliope.core.OrderListener import OrderListener
 
-# API
-from flask import Flask
-from kalliope.core.RestAPI.FlaskAPI import FlaskAPI
+from kalliope import Utils, BrainLoader
+from kalliope.neurons.say import Say
 
-# Launchers
-from kalliope.core.SynapseLauncher import SynapseLauncher
 from kalliope.core.TriggerLauncher import TriggerLauncher
-from kalliope.core.Utils.RpiUtils import RpiUtils
+from transitions import Machine
+
 from kalliope.core.PlayerLauncher import PlayerLauncher
 
-# Neurons
-from kalliope.neurons.say.say import Say
+from kalliope.core.ConfigurationManager import SettingLoader
 
 logging.basicConfig()
 logger = logging.getLogger("kalliope")
 
 
-class MainController:
-    """
-    This Class is the global controller of the application.
-    """
+class Order(Thread):
     states = ['init',
               'starting_trigger',
               'playing_ready_sound',
@@ -38,16 +34,30 @@ class MainController:
               'waiting_for_order_listener_callback',
               'analysing_order']
 
-    def __init__(self, brain=None):
-        self.brain = brain
-        # get global configuration
+    def __init__(self):
+        super(Order, self).__init__()
+        Utils.print_info('Starting voice order manager')
+        # load settings and brain from singleton
         sl = SettingLoader()
         self.settings = sl.settings
+        self.brain = BrainLoader().get_brain()
+
         # keep in memory the order to process
         self.order_to_process = None
 
-        # Starting the rest API
-        self._start_rest_api()
+        # get the player instance
+        self.player_instance = PlayerLauncher.get_player(settings=self.settings)
+
+        # save an instance of the trigger
+        self.trigger_instance = None
+        self.trigger_callback_called = False
+
+        # save the current order listener
+        self.order_listener = None
+        self.order_listener_callback_called = False
+
+        # boolean used to know id we played the on ready notification at least one time
+        self.on_ready_notification_played_once = False
 
         # rpi setting for led and mute button
         self.rpi_utils = None
@@ -64,22 +74,8 @@ class MainController:
                 logger.debug("[MainController] Switching pin_led_started to ON")
                 RpiUtils.switch_pin_to_on(self.settings.rpi_settings.pin_led_started)
 
-        # get the player instance
-        self.player_instance = PlayerLauncher.get_player(settings=self.settings)
-
-        # save an instance of the trigger
-        self.trigger_instance = None
-        self.trigger_callback_called = False
-
-        # save the current order listener
-        self.order_listener = None
-        self.order_listener_callback_called = False
-
-        # boolean used to know id we played the on ready notification at least one time
-        self.on_ready_notification_played_once = False
-
         # Initialize the state machine
-        self.machine = Machine(model=self, states=MainController.states, initial='init', queued=True)
+        self.machine = Machine(model=self, states=Order.states, initial='init', queued=True)
 
         # define transitions
         self.machine.add_transition('start_trigger', ['init', 'analysing_order'], 'starting_trigger')
@@ -102,6 +98,7 @@ class MainController:
         self.machine.on_enter_waiting_for_order_listener_callback('waiting_for_order_listener_callback_thread')
         self.machine.on_enter_analysing_order('analysing_order_thread')
 
+    def run(self):
         self.start_trigger()
 
     def start_trigger_process(self):
@@ -168,7 +165,7 @@ class MainController:
     def stop_trigger_process(self):
         """
         The trigger has been awaken, we don't needed it anymore
-        :return: 
+        :return:
         """
         logger.debug("[MainController] Entering state: %s" % self.state)
         self.trigger_instance.stop()
@@ -237,21 +234,6 @@ class MainController:
         logger.debug("[MainController] Selected sound: %s" % random_path)
         return Utils.get_real_file_path(random_path)
 
-    def _start_rest_api(self):
-        """
-        Start the Rest API if asked in the user settings
-        """
-        # run the api if the user want it
-        if self.settings.rest_api.active:
-            Utils.print_info("Starting REST API Listening port: %s" % self.settings.rest_api.port)
-            app = Flask(__name__)
-            flask_api = FlaskAPI(app=app,
-                                 port=self.settings.rest_api.port,
-                                 brain=self.brain,
-                                 allowed_cors_origin=self.settings.rest_api.allowed_cors_origin)
-            flask_api.daemon = True
-            flask_api.start()
-
     def muted_button_pressed(self, muted=False):
         logger.debug("[MainController] Mute button pressed. Switch trigger process to muted: %s" % muted)
         if muted:

+ 0 - 0
kalliope/signals/order/tests/__init__.py


+ 11 - 0
kalliope/signals/order/tests/test_order.py

@@ -0,0 +1,11 @@
+# def test_check_order_dict(self):
+#     valid_order = 'test_order'
+#     invalid_order = ''
+#     invalid_order2 = None
+#
+#     self.assertTrue(ConfigurationChecker.check_order_dict(valid_order))
+#
+#     with self.assertRaises(NoValidOrder):
+#         ConfigurationChecker.check_order_dict(invalid_order)
+#     with self.assertRaises(NoValidOrder):
+#         ConfigurationChecker.check_order_dict(invalid_order2)