Debian Codegraph @

tests/links_test.py

raw symbols SCIP
1 # Copyright (C) 2021 Christian Ledermann
2 #
3 # This library is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU Lesser General Public License as published by the Free
5 # Software Foundation; either version 2.1 of the License, or (at your option)
6 # any later version.
7 #
8 # This library is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 # details.
12 #
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this library; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 """Test the kml classes."""
18
19 from fastkml import links
20 from fastkml.enums import RefreshMode
21 from fastkml.enums import ViewRefreshMode
22 from tests.base import Lxml
23 from tests.base import StdLibrary
24
25
26 class TestStdLibrary(StdLibrary):
27 """Test with the standard library."""
28
29 def test_icon(self) -> None:
30 """Test the Icon class."""
31 icon_0 = links.Icon(
32 id="icon-01",
33 href="http://maps.google.com/mapfiles/kml/paddle/red-circle.png",
34 refresh_mode=RefreshMode("onInterval"),
35 refresh_interval=60,
36 view_refresh_mode=ViewRefreshMode("onStop"),
37 view_refresh_time=4,
38 view_bound_scale=1.2,
39 view_format="BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]",
40 http_query="clientName=fastkml",
41 )
42
43 icon = links.Icon.from_string(icon_0.to_string())
44
45 assert icon.id == "icon-01"
46 assert icon.href == "http://maps.google.com/mapfiles/kml/paddle/red-circle.png"
47 assert icon.refresh_mode == RefreshMode("onInterval")
48 assert icon.refresh_interval == 60
49 assert icon.view_refresh_mode == ViewRefreshMode("onStop")
50 assert icon.view_refresh_time == 4
51 assert icon.view_bound_scale == 1.2
52 assert icon.view_format == "BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]"
53 assert icon.http_query == "clientName=fastkml"
54
55 def test_icon_read(self) -> None:
56 """Test the Icon class."""
57 icon = links.Icon.from_string(
58 """
59 <kml:Icon xmlns:kml="http://www.opengis.net/kml/2.2" id="icon-01">
60 <kml:href>http://maps.google.com/mapfiles/kml/paddle/red-circle.png</kml:href>
61 <kml:refreshMode>onInterval</kml:refreshMode>
62 <kml:refreshInterval>60</kml:refreshInterval>
63 <kml:viewRefreshMode>onStop</kml:viewRefreshMode>
64 <kml:viewRefreshTime>4</kml:viewRefreshTime>
65 <kml:viewBoundScale>1.2</kml:viewBoundScale>
66 <kml:viewFormat>BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</kml:viewFormat>
67 <kml:httpQuery>clientName=fastkml</kml:httpQuery>
68 </kml:Icon>
69 """.strip(),
70 )
71
72 assert icon.id == "icon-01"
73 assert icon.href == "http://maps.google.com/mapfiles/kml/paddle/red-circle.png"
74 assert icon.refresh_mode == RefreshMode("onInterval")
75 assert icon.refresh_interval == 60
76 assert icon.view_refresh_mode == ViewRefreshMode("onStop")
77 assert icon.view_refresh_time == 4
78 assert icon.view_bound_scale == 1.2
79 assert icon.view_format == "BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]"
80 assert icon.http_query == "clientName=fastkml"
81
82 icon2 = links.Icon.from_string(icon.to_string())
83
84 assert icon2.to_string() == icon.to_string()
85
86
87 class TestLxml(Lxml, TestStdLibrary):
88 """Test with lxml."""