From 09f8bb8ed703e664f40b3a63a8a0e0fd73193e7d Mon Sep 17 00:00:00 2001 From: apurvabanka Date: Thu, 14 Nov 2024 01:54:59 -0500 Subject: [PATCH] Requested changes and deleting the output files --- tests/kml_test.py | 23 ++++++++++++++++++++-- tests/ogc_conformance/data/kml/output.kml | 2 -- tests/ogc_conformance/data/kml/output.kmz | Bin 273 -> 0 bytes 3 files changed, 21 insertions(+), 4 deletions(-) delete mode 100644 tests/ogc_conformance/data/kml/output.kml delete mode 100644 tests/ogc_conformance/data/kml/output.kmz diff --git a/tests/kml_test.py b/tests/kml_test.py index fb04fb25..547161b7 100644 --- a/tests/kml_test.py +++ b/tests/kml_test.py @@ -18,6 +18,7 @@ import io import pathlib +import zipfile import pygeoif as geo import pytest @@ -209,10 +210,16 @@ def test_write_kml_file(self) -> None: ) file_path = KMLFILEDIR / "output.kml" - doc.write(file_path=file_path, prettyprint=True, xml_declaration=True) + doc.write(file_path=file_path, prettyprint=True, xml_declaration=False) assert file_path.is_file(), "KML file was not created." + parsed_doc = kml.KML.parse(file_path) + + assert parsed_doc.to_string() == doc.to_string(), "Written and original documents don't match" + + file_path.unlink() + def test_write_kmz_file(self) -> None: doc = kml.KML( @@ -236,10 +243,22 @@ def test_write_kmz_file(self) -> None: file_path = KMLFILEDIR / "output.kmz" - doc.write(file_path=file_path, prettyprint=True, xml_declaration=True) + doc.write(file_path=file_path, prettyprint=True, xml_declaration=False) assert file_path.is_file(), "KMZ file was not created." + tree = doc.to_string() + + with zipfile.ZipFile(file_path, 'r') as kmz: + assert 'doc.kml' in kmz.namelist(), "doc.kml not found in the KMZ file" + + with kmz.open('doc.kml') as doc_kml: + kml_content = doc_kml.read().decode("utf-8") + + assert kml_content == tree, "KML content does not match expected content" + + file_path.unlink() + class TestLxml(Lxml, TestStdLibrary): """Test with lxml.""" diff --git a/tests/ogc_conformance/data/kml/output.kml b/tests/ogc_conformance/data/kml/output.kml deleted file mode 100644 index 1bf68287..00000000 --- a/tests/ogc_conformance/data/kml/output.kml +++ /dev/null @@ -1,2 +0,0 @@ - -Vestibulum eleifend lobortis lorem. \ No newline at end of file diff --git a/tests/ogc_conformance/data/kml/output.kmz b/tests/ogc_conformance/data/kml/output.kmz deleted file mode 100644 index bc737f2d7353ab51602cd510b5a879b62ffd1180..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 273 zcmWIWW@Zs#U|`^2kQB>}RBcVVun@?*0mSS;oRXicmz|qq+q;pk$v~o|eEy=umoD5s zZ5K94q_dZ@|60xaHvW>>$B%0}_@>`^y8E>0+tX5?Smd`jJ9>u&Fj-hE{iyfiY0a7M zTc++#+p^40X=U%j$1dMG3RhXiPix)D`C%QibBB##+(xa*ub(|=yUFCXXzGb6(w`P- zn77Pjt!x!2wV!=c$Y4Q!Lzl#LYxz=-W6i0&|F>Vid$NT2#<~8M)B3;X<`{bJV+`