Skip to content

Commit

Permalink
Requested changes and deleting the output files
Browse files Browse the repository at this point in the history
  • Loading branch information
apurvabanka committed Nov 14, 2024
1 parent 6a13db7 commit 09f8bb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
23 changes: 21 additions & 2 deletions tests/kml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io
import pathlib
import zipfile

import pygeoif as geo
import pytest
Expand Down Expand Up @@ -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(
Expand All @@ -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."""
Expand Down
2 changes: 0 additions & 2 deletions tests/ogc_conformance/data/kml/output.kml

This file was deleted.

Binary file removed tests/ogc_conformance/data/kml/output.kmz
Binary file not shown.

0 comments on commit 09f8bb8

Please sign in to comment.