forked from sportorg/pysport
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: coordinates import (GPX, IOF XML, CSV)
- Loading branch information
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
start, 0, 0, | ||
31, 100, -359, | ||
32, -214, -462, | ||
33, -574, -309, | ||
34, -482, 82, | ||
finish, -194, 177, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> | ||
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="http://nakarte.me" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1"> | ||
<metadata> | ||
<time>2024-12-09T11:18:14.987Z</time> | ||
</metadata> | ||
<wpt lat="55.753317" lon="37.621758"> | ||
<name>start</name> | ||
</wpt> | ||
<wpt lat="55.750110" lon="37.623464"> | ||
<name>31</name> | ||
</wpt> | ||
<wpt lat="55.749132" lon="37.618496"> | ||
<name>32</name> | ||
</wpt> | ||
<wpt lat="55.750440" lon="37.612719"> | ||
<name>33</name> | ||
</wpt> | ||
<wpt lat="55.753975" lon="37.614060"> | ||
<name>34</name> | ||
</wpt> | ||
<wpt lat="55.754874" lon="37.618614"> | ||
<name>finish</name> | ||
</wpt> | ||
</gpx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CourseData xmlns="http://www.orienteering.org/datastandard/3.0" iofVersion="3.0" creator="OpenOrienteering Mapper 0.9.6" createTime="2024-12-09T16:01:14"> | ||
<Event> | ||
<Name>Test event</Name> | ||
</Event> | ||
<RaceCourseData> | ||
<Control> | ||
<Id>S1</Id> | ||
<Position lng="37.621758" lat="55.753317"/> | ||
</Control> | ||
<Control> | ||
<Id>31</Id> | ||
<Position lng="37.623464" lat="55.75011"/> | ||
</Control> | ||
<Control> | ||
<Id>32</Id> | ||
<Position lng="37.6184959" lat="55.749132"/> | ||
</Control> | ||
<Control> | ||
<Id>33</Id> | ||
<Position lng="37.6127191" lat="55.75044"/> | ||
</Control> | ||
<Control> | ||
<Id>34</Id> | ||
<Position lng="37.61406" lat="55.753975"/> | ||
</Control> | ||
<Control> | ||
<Id>F1</Id> | ||
<Position lng="37.6186141" lat="55.754874"/> | ||
</Control> | ||
<Course> | ||
<Name>Test course</Name> | ||
<CourseControl type="Start"> | ||
<Control>S1</Control> | ||
</CourseControl> | ||
<CourseControl type="Control"> | ||
<Control>31</Control> | ||
</CourseControl> | ||
<CourseControl type="Control"> | ||
<Control>32</Control> | ||
</CourseControl> | ||
<CourseControl type="Control"> | ||
<Control>33</Control> | ||
</CourseControl> | ||
<CourseControl type="Control"> | ||
<Control>34</Control> | ||
</CourseControl> | ||
<CourseControl type="Finish"> | ||
<Control>F1</Control> | ||
</CourseControl> | ||
</Course> | ||
</RaceCourseData> | ||
</CourseData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
|
||
from sportorg.models.memory import race | ||
from sportorg.modules.coordinates.coordinates import import_coordinates_from_gpx, import_coordinates_from_iof_xml, import_coordinates_from_csv | ||
|
||
@pytest.mark.parametrize( | ||
'file_name, function', | ||
[ | ||
('course.gpx', import_coordinates_from_gpx), | ||
('course.xml', import_coordinates_from_iof_xml), | ||
('course.csv', import_coordinates_from_csv), | ||
] | ||
) | ||
|
||
def test_import_coordinates_from_gpx(file_name, function): | ||
cur_race = race() | ||
cur_race.control_points = [] # Clear control points to ensure test isolation | ||
|
||
function('tests/data/' + file_name) | ||
assert len(cur_race.control_points) == 6 | ||
|
||
expected = [ | ||
('31', 3, 100, -359), | ||
('32', 3, -214, -462), | ||
('33', 3, -574, -309), | ||
('34', 3, -482, 82), | ||
('finish', 0, -194, 177), | ||
('start', 0, 0, 0), | ||
] | ||
|
||
for i, (code, score, x, y) in enumerate(expected): | ||
cp = cur_race.control_points[i] | ||
assert cp.code == code | ||
assert cp.score == score | ||
assert cp.x == x | ||
assert cp.y == y | ||
|