Переглянути джерело

[Tests] complete tests of OrderAnalyser method _get_matching_synapse_list

monf 8 роки тому
батько
коміт
a54c6f51fd
1 змінених файлів з 47 додано та 3 видалено
  1. 47 3
      core/Tests/test_order_analyser.py

+ 47 - 3
core/Tests/test_order_analyser.py

@@ -206,7 +206,7 @@ class TestOrderAnalyser(unittest.TestCase):
 
         signal1 = Order(sentence="this is the sentence")
         signal2 = Order(sentence="this is the second sentence")
-        signal3 = Order(sentence="this is the third 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])
@@ -223,9 +223,53 @@ class TestOrderAnalyser(unittest.TestCase):
         self.assertEquals(OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
                                                                    order_to_match=order_to_match),
                           expected_result,
-                          "Fail matching the expected synapse from the complete synapse list and the order")
+                          "Fail matching 'the expected synapse' from the complete synapse list and the order")
 
-        # TODO : to be continued
+        # 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]
+        self.assertEquals(OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
+                                                                   order_to_match=order_to_match),
+                          expected_result,
+                          "Fail 'Multiple Matching synapses' from the complete synapse list and the order")
+
+        # 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]
+
+        self.assertEquals(OrderAnalyser._get_matching_synapse_list(all_synapses_list=all_synapse_list,
+                                                                   order_to_match=order_to_match),
+                          expected_result,
+                          "Fail matching 'synapse with all key worlds' from the complete synapse list and the order")
 
     def test_get_synapse_params(self):
         # Init