Skip to content

Commit f1db625

Browse files
committed
test: merge test improvements from feature branch (Phase 6)
- Apply feature branch formatting improvements to test_TouchTerrainGPX.py - Update test_TouchTerrain_standalone.py to use correct function signature - Apply formatting improvements to test data files - All tests passing (7 passed, 20 skipped)
1 parent 9e8e750 commit f1db625

File tree

3 files changed

+172
-48
lines changed

3 files changed

+172
-48
lines changed

test/sheepMtn_outline.kml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@
1212
<Placemark id="ID_00000">
1313
<name>62553.142231211357</name>
1414
<snippet></snippet>
15-
<description><![CDATA[<html xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
16-
<head>
17-
<META http-equiv="Content-Type" content="text/html">
18-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
19-
</head>
20-
<body style="margin:0px 0px 0px 0px;overflow:auto;background:#FFFFFF;">
21-
<table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-collapse:collapse;padding:3px 3px 3px 3px">
22-
<tr style="text-align:center;font-weight:bold;background:#9CBCE2">
23-
<td>62553.1422312114</td>
24-
</tr>
25-
<tr>
26-
<td>
27-
<table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px">
28-
<tr>
29-
<td>SHAPE</td>
30-
<td>Polygon</td>
31-
</tr>
32-
</table>
33-
</td>
34-
</tr>
35-
</table>
36-
</body><script type="text/javascript">
37-
function changeImage(attElement, nameElement) {
38-
document.getElementById('imageAttachment').src = attElement;
39-
document.getElementById('imageName').innerHTML = nameElement;}
40-
</script></html>
15+
<description><![CDATA[<html xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
16+
<head>
17+
<META http-equiv="Content-Type" content="text/html">
18+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
19+
</head>
20+
<body style="margin:0px 0px 0px 0px;overflow:auto;background:#FFFFFF;">
21+
<table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-collapse:collapse;padding:3px 3px 3px 3px">
22+
<tr style="text-align:center;font-weight:bold;background:#9CBCE2">
23+
<td>62553.1422312114</td>
24+
</tr>
25+
<tr>
26+
<td>
27+
<table style="font-family:Arial,Verdana,Times;font-size:12px;text-align:left;width:100%;border-spacing:0px; padding:3px 3px 3px 3px">
28+
<tr>
29+
<td>SHAPE</td>
30+
<td>Polygon</td>
31+
</tr>
32+
</table>
33+
</td>
34+
</tr>
35+
</table>
36+
</body><script type="text/javascript">
37+
function changeImage(attElement, nameElement) {
38+
document.getElementById('imageAttachment').src = attElement;
39+
document.getElementById('imageName').innerHTML = nameElement;}
40+
</script></html>
4141
]]></description>
4242
<styleUrl>#PolyStyle00</styleUrl>
4343
<MultiGeometry>
@@ -63,4 +63,4 @@
6363
</PolyStyle>
6464
</Style>
6565
</Document>
66-
</kml>
66+
</kml>

test/test_TouchTerrainGPX.py

Lines changed: 144 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import unittest
1+
import unittest
2+
23
import numpy
4+
35
from touchterrain.common.TouchTerrainGPX import plotLineWithThickness
46

57
grid_width = 10
@@ -8,53 +10,155 @@
810
height_offset = 5
911
line_height = original_height + height_offset
1012

13+
1114
class PlotLineTests(unittest.TestCase):
1215

1316
def _print_points(self):
1417
print(self.points)
15-
18+
1619
def _assert_expected_line_points(self, expected_line_points):
1720
# iterate over the entire grid making sure only the expected line points have the increased height
1821
for x in range(grid_width):
1922
for y in range(grid_height):
2023
if [x, y] in expected_line_points:
21-
self.assertEqual(self.points[x][y], line_height, "Point [{},{}] expected to be on the line but actually isn't".format(x, y))
24+
self.assertEqual(
25+
self.points[x][y],
26+
line_height,
27+
"Point [{},{}] expected to be on the line but actually isn't".format(
28+
x, y
29+
),
30+
)
2231
else:
23-
self.assertEqual(self.points[x][y], original_height, "Point [{},{}] expected not to be on the line but actually is".format(x, y))
32+
self.assertEqual(
33+
self.points[x][y],
34+
original_height,
35+
"Point [{},{}] expected not to be on the line but actually is".format(
36+
x, y
37+
),
38+
)
2439

2540
def setUp(self):
26-
self.points = numpy.full(shape=(grid_width, grid_height),fill_value=original_height)
41+
self.points = numpy.full(
42+
shape=(grid_width, grid_height), fill_value=original_height
43+
)
2744
self.pathed_points = {}
2845

2946
def test_plot_vertical_line_with_zero_thickness(self):
30-
plotLineWithThickness(3, 2, 3, 6, height_offset, self.points, self.pathed_points, 0)
47+
plotLineWithThickness(
48+
3, 2, 3, 6, height_offset, self.points, self.pathed_points, 0
49+
)
3150
# self._print_points()
32-
self._assert_expected_line_points([[3,2], [3,3], [3,4], [3,5], [3,6]])
51+
self._assert_expected_line_points([[3, 2], [3, 3], [3, 4], [3, 5], [3, 6]])
3352

3453
def test_plot_horizontal_line_with_zero_thickness(self):
35-
plotLineWithThickness(2, 4, 5, 4, height_offset, self.points, self.pathed_points, 0)
54+
plotLineWithThickness(
55+
2, 4, 5, 4, height_offset, self.points, self.pathed_points, 0
56+
)
3657
# self._print_points()
37-
self._assert_expected_line_points([[2,4], [3,4], [4,4], [5,4]])
58+
self._assert_expected_line_points([[2, 4], [3, 4], [4, 4], [5, 4]])
3859

3960
def test_plot_vertical_line_with_nonzero_thickness(self):
40-
plotLineWithThickness(3, 2, 3, 5, height_offset, self.points, self.pathed_points, 3)
61+
plotLineWithThickness(
62+
3, 2, 3, 5, height_offset, self.points, self.pathed_points, 3
63+
)
4164
# self._print_points()
42-
self._assert_expected_line_points([[2,2], [3,2], [4,2], [2,3], [3,3], [4,3], [2,4], [3,4], [4,4], [2,5], [3,5], [4,5]])
65+
self._assert_expected_line_points(
66+
[
67+
[2, 2],
68+
[3, 2],
69+
[4, 2],
70+
[2, 3],
71+
[3, 3],
72+
[4, 3],
73+
[2, 4],
74+
[3, 4],
75+
[4, 4],
76+
[2, 5],
77+
[3, 5],
78+
[4, 5],
79+
]
80+
)
4381

4482
def test_plot_horizontal_line_with_nonzero_thickness(self):
45-
plotLineWithThickness(2, 4, 6, 4, height_offset, self.points, self.pathed_points, 3)
83+
plotLineWithThickness(
84+
2, 4, 6, 4, height_offset, self.points, self.pathed_points, 3
85+
)
4686
# self._print_points()
47-
self._assert_expected_line_points([[2,3], [2,4], [2,5], [3,3], [3,4], [3,5], [4,3], [4,4], [4,5], [5,3], [5,4], [5,5], [6,3], [6,4], [6,5]])
87+
self._assert_expected_line_points(
88+
[
89+
[2, 3],
90+
[2, 4],
91+
[2, 5],
92+
[3, 3],
93+
[3, 4],
94+
[3, 5],
95+
[4, 3],
96+
[4, 4],
97+
[4, 5],
98+
[5, 3],
99+
[5, 4],
100+
[5, 5],
101+
[6, 3],
102+
[6, 4],
103+
[6, 5],
104+
]
105+
)
48106

49107
def test_plot_sw_ne_low_slope_diagonal_line_with_nonzero_thickness(self):
50-
plotLineWithThickness(1, 3, 6, 5, height_offset, self.points, self.pathed_points, 3)
108+
plotLineWithThickness(
109+
1, 3, 6, 5, height_offset, self.points, self.pathed_points, 3
110+
)
51111
# self._print_points()
52-
self._assert_expected_line_points([[1,2], [1,3], [1,4], [2,2], [2,3], [2,4], [3,3], [3,4], [3,5], [4,3], [4,4], [4,5], [5,4], [5,5], [5,6], [6,4], [6,5], [6,6]])
112+
self._assert_expected_line_points(
113+
[
114+
[1, 2],
115+
[1, 3],
116+
[1, 4],
117+
[2, 2],
118+
[2, 3],
119+
[2, 4],
120+
[3, 3],
121+
[3, 4],
122+
[3, 5],
123+
[4, 3],
124+
[4, 4],
125+
[4, 5],
126+
[5, 4],
127+
[5, 5],
128+
[5, 6],
129+
[6, 4],
130+
[6, 5],
131+
[6, 6],
132+
]
133+
)
53134

54135
def test_plot_se_nw_high_slope_diagonal_line_with_nonzero_thickness(self):
55-
plotLineWithThickness(5, 6, 3, 1, height_offset, self.points, self.pathed_points, 3)
136+
plotLineWithThickness(
137+
5, 6, 3, 1, height_offset, self.points, self.pathed_points, 3
138+
)
56139
# self._print_points()
57-
self._assert_expected_line_points([[4,6], [5,6], [6,6], [4,5], [5,5], [6,5], [3,4], [4,4], [5,4], [3,3], [4,3], [5,3], [2,2], [3,2], [4,2], [2,1], [3,1], [4,1]])
140+
self._assert_expected_line_points(
141+
[
142+
[4, 6],
143+
[5, 6],
144+
[6, 6],
145+
[4, 5],
146+
[5, 5],
147+
[6, 5],
148+
[3, 4],
149+
[4, 4],
150+
[5, 4],
151+
[3, 3],
152+
[4, 3],
153+
[5, 3],
154+
[2, 2],
155+
[3, 2],
156+
[4, 2],
157+
[2, 1],
158+
[3, 1],
159+
[4, 1],
160+
]
161+
)
58162

59163
def test_plot_line_with_nonzero_thickness_draws_flat_topped_line(self):
60164
# Set some of the points either side of the centre to be higher - track should not just add the offset to
@@ -64,10 +168,30 @@ def test_plot_line_with_nonzero_thickness_draws_flat_topped_line(self):
64168
self.points[5][5] = original_height + 3
65169
self.points[5][6] = original_height + 4
66170

67-
plotLineWithThickness(3, 4, 5, 4, height_offset, self.points, self.pathed_points, 5)
171+
plotLineWithThickness(
172+
3, 4, 5, 4, height_offset, self.points, self.pathed_points, 5
173+
)
68174
# self._print_points()
69-
self._assert_expected_line_points([[3,2], [3,3], [3,4], [3,5], [3,6], [4,2], [4,3], [4,4], [4,5], [4,6], [5,2], [5,3], [5,4], [5,5], [5,6]])
175+
self._assert_expected_line_points(
176+
[
177+
[3, 2],
178+
[3, 3],
179+
[3, 4],
180+
[3, 5],
181+
[3, 6],
182+
[4, 2],
183+
[4, 3],
184+
[4, 4],
185+
[4, 5],
186+
[4, 6],
187+
[5, 2],
188+
[5, 3],
189+
[5, 4],
190+
[5, 5],
191+
[5, 6],
192+
]
193+
)
70194

71195

72-
if __name__ == '__main__':
196+
if __name__ == "__main__":
73197
unittest.main(verbosity=3)

test/test_TouchTerrain_standalone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_get_zipped_tiles(overwrite_args, testname):
5454
for k in sorted(args.keys()):
5555
print("%s = %s" % (k, str(args[k])))
5656

57-
totalsize, full_zip_file_name = TouchTerrain.get_zipped_tiles(args)
57+
totalsize, full_zip_file_name = TouchTerrain.get_zipped_tiles(**args)
5858
# print("In tmp, created zip file", full_zip_file_name, "%.2f" % totalsize, "Mb")
5959

6060
from os import getcwd, remove, sep

0 commit comments

Comments
 (0)