# Copyright (C) 2021 Christian Ledermann # # This library is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation; either version 2.1 of the License, or (at your option) # any later version. # # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """Test the kml classes.""" from fastkml import links from fastkml.enums import RefreshMode from fastkml.enums import ViewRefreshMode from tests.base import Lxml from tests.base import StdLibrary class TestStdLibrary(StdLibrary): """Test with the standard library.""" def test_icon(self) -> None: """Test the Icon class.""" icon_0 = links.Icon( id="icon-01", href="http://maps.google.com/mapfiles/kml/paddle/red-circle.png", refresh_mode=RefreshMode("onInterval"), refresh_interval=60, view_refresh_mode=ViewRefreshMode("onStop"), view_refresh_time=4, view_bound_scale=1.2, view_format="BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]", http_query="clientName=fastkml", ) icon = links.Icon.from_string(icon_0.to_string()) assert icon.id == "icon-01" assert icon.href == "http://maps.google.com/mapfiles/kml/paddle/red-circle.png" assert icon.refresh_mode == RefreshMode("onInterval") assert icon.refresh_interval == 60 assert icon.view_refresh_mode == ViewRefreshMode("onStop") assert icon.view_refresh_time == 4 assert icon.view_bound_scale == 1.2 assert icon.view_format == "BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]" assert icon.http_query == "clientName=fastkml" def test_icon_read(self) -> None: """Test the Icon class.""" icon = links.Icon.from_string( """ http://maps.google.com/mapfiles/kml/paddle/red-circle.png onInterval 60 onStop 4 1.2 BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth] clientName=fastkml """.strip(), ) assert icon.id == "icon-01" assert icon.href == "http://maps.google.com/mapfiles/kml/paddle/red-circle.png" assert icon.refresh_mode == RefreshMode("onInterval") assert icon.refresh_interval == 60 assert icon.view_refresh_mode == ViewRefreshMode("onStop") assert icon.view_refresh_time == 4 assert icon.view_bound_scale == 1.2 assert icon.view_format == "BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]" assert icon.http_query == "clientName=fastkml" icon2 = links.Icon.from_string(icon.to_string()) assert icon2.to_string() == icon.to_string() class TestLxml(Lxml, TestStdLibrary): """Test with lxml."""