|
@@ -0,0 +1,48 @@
|
|
1
|
+# coding: utf-8
|
|
2
|
+import pytest
|
|
3
|
+
|
|
4
|
+from synergine2_xyz.physics import VisibilityMatrix
|
|
5
|
+from tests import BaseTest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+class TestVisibilityMatrix(BaseTest):
|
|
9
|
+ def test_initialize_empty_matrix(self):
|
|
10
|
+ visibility = VisibilityMatrix()
|
|
11
|
+ visibility.initialize_empty_matrix('testing', height=0.5, matrix_width=3, matrix_height=2)
|
|
12
|
+ matrix = visibility.get_matrix('testing', height=0.5)
|
|
13
|
+
|
|
14
|
+ assert isinstance(matrix, list)
|
|
15
|
+
|
|
16
|
+ assert [0.0, 0.0, 0.0] == matrix[0]
|
|
17
|
+ assert [0.0, 0.0, 0.0] == matrix[1]
|
|
18
|
+
|
|
19
|
+ def test_update_matrix(self):
|
|
20
|
+ visibility = VisibilityMatrix()
|
|
21
|
+ visibility.initialize_empty_matrix('testing', height=0.5, matrix_width=3, matrix_height=2)
|
|
22
|
+ visibility.update_matrix('testing', height=0.5, x=2, y=1, value=0.5)
|
|
23
|
+ visibility.update_matrix('testing', height=0.5, x=0, y=0, value=0.7)
|
|
24
|
+ matrix = visibility.get_matrix('testing', height=0.5)
|
|
25
|
+
|
|
26
|
+ assert [0.7, 0.0, 0.0] == matrix[0]
|
|
27
|
+ assert [0.0, 0.0, 0.5] == matrix[1]
|
|
28
|
+
|
|
29
|
+ @pytest.mark.skip(reason='Not implemented yet')
|
|
30
|
+ def test_get_path_positions(self):
|
|
31
|
+ visibility = VisibilityMatrix()
|
|
32
|
+ visibility.initialize_empty_matrix('testing', height=0.5, matrix_width=3, matrix_height=2)
|
|
33
|
+ visibility.update_matrix('testing', height=0.5, x=2, y=1, value=0.5)
|
|
34
|
+ visibility.update_matrix('testing', height=0.5, x=0, y=0, value=0.7)
|
|
35
|
+
|
|
36
|
+ path_positions = visibility.get_path_positions(from_=(0, 0), to=(2, 1))
|
|
37
|
+ assert [(0, 0), (0, 1), (1, 2)] == path_positions
|
|
38
|
+
|
|
39
|
+ @pytest.mark.skip(reason='Not implemented yet')
|
|
40
|
+ def test_get_path_values(self):
|
|
41
|
+ visibility = VisibilityMatrix()
|
|
42
|
+ visibility.initialize_empty_matrix('testing', height=0.5, matrix_width=3, matrix_height=2)
|
|
43
|
+ visibility.update_matrix('testing', height=0.5, x=2, y=1, value=0.5)
|
|
44
|
+ visibility.update_matrix('testing', height=0.5, x=0, y=0, value=0.7)
|
|
45
|
+
|
|
46
|
+ path_positions = visibility.get_path_positions(from_=(0, 0), to=(2, 1))
|
|
47
|
+ path_values = visibility.get_values_for_path(path_positions=path_positions)
|
|
48
|
+ assert [0.7, 0.0, 0.5] == path_values
|