Browse Source

add tests on founf direction of pheromone

Bastien Sevajol 9 years ago
parent
commit
35b95e8b11
1 changed files with 38 additions and 5 deletions
  1. 38 5
      intelligine/tests/simulation/pheromone/TestDirection.py

+ 38 - 5
intelligine/tests/simulation/pheromone/TestDirection.py View File

@@ -32,13 +32,31 @@ class TestDirection(Base):
32 32
         :param direction:
33 33
         :param pheromone_type:
34 34
         :param reference_point:
35
-        :return: void
35
+        :return:
36 36
         """
37 37
         self._set_up_pheromones(pheromones)
38 38
         direction_tested = DirectionPheromone.get_direction_for_point(self._context, reference_point, pheromone_type)
39 39
         self.assertEqual(direction, direction_tested, "Direction must be %s" % direction)
40 40
 
41
-    def test_direct_route(self):
41
+    def _test_direction_for_points(self, pheromones, direction, pheromone_type=PHEROMON_DIR_EXPLO,
42
+                                   reference_point=(0, 0, 0)):
43
+        """
44
+
45
+        :param pheromones:
46
+        :param direction:
47
+        :param pheromone_type:
48
+        :param reference_point:
49
+        :return:
50
+        """
51
+        self._set_up_pheromones(pheromones)
52
+        around_points = self._context.get_arround_points_of(reference_point)
53
+        direction_tested = DirectionPheromone.get_best_pheromone_direction_in(self._context,
54
+                                                                              reference_point,
55
+                                                                              around_points,
56
+                                                                              pheromone_type)
57
+        self.assertEqual(direction, direction_tested, "Direction must be %s" % direction)
58
+
59
+    def test_route_direct_route(self):
42 60
         """
43 61
         Test easy direction with 1 best pheromones just near actual position
44 62
         :return:
@@ -81,7 +99,7 @@ class TestDirection(Base):
81 99
         for direction_wanted in test_data:
82 100
             self._test_direction_for_point(test_data[direction_wanted], direction_wanted)
83 101
 
84
-    def test_with_multiple_same_intensity(self):
102
+    def test_route_with_multiple_same_intensity(self):
85 103
         """
86 104
         Test find route in middle of multiple pheromones
87 105
         :return:
@@ -103,7 +121,7 @@ class TestDirection(Base):
103 121
         for direction_wanted in test_data:
104 122
             self._test_direction_for_point(test_data[direction_wanted], direction_wanted)
105 123
 
106
-    def test_with_multiple_different_intensity(self):
124
+    def test_route_with_multiple_different_intensity(self):
107 125
         """
108 126
         Test find route in middle of multiple pheromones
109 127
         :return:
@@ -117,4 +135,19 @@ class TestDirection(Base):
117 135
         }
118 136
 
119 137
         for direction_wanted in test_data:
120
-            self._test_direction_for_point(test_data[direction_wanted], direction_wanted)
138
+            self._test_direction_for_point(test_data[direction_wanted], direction_wanted)
139
+
140
+    def test_direction_direct(self):
141
+        test_data = {
142
+            11: {
143
+                (0, 0, -1): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}}
144
+            }
145
+        }
146
+        self._test_direction_for_points({(0, 0, -1): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 2)}}},
147
+                                        11)
148
+
149
+    def test_direction_with_multiple_intensity(self):
150
+        self._test_direction_for_points({(0, 0, -1): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 5)}},
151
+                                         (0, 1, 1): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}},
152
+                                         (0, -1, -1): {PHEROMON_DIRECTION: {PHEROMON_DIR_EXPLO: (9, 4)}}},
153
+                                        11)