From 2c0c30ad330dcf14117f7b5b6c6461abcdd0f776 Mon Sep 17 00:00:00 2001 From: Guille Date: Tue, 1 Dec 2020 16:29:20 -0500 Subject: [PATCH] Remove debug message --- tests/test_geometry_factory.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_geometry_factory.py b/tests/test_geometry_factory.py index 3e810831..75f5f8be 100644 --- a/tests/test_geometry_factory.py +++ b/tests/test_geometry_factory.py @@ -4,6 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ import os +import pickle from pathlib import Path from unittest import TestCase @@ -21,6 +22,7 @@ class TestGeometryFactory(TestCase): """ self._city_gml = None self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve() + self._pickle_file = (self._example_path / 'city.pickle').resolve() def _get_citygml(self): if self._city_gml is None: @@ -54,6 +56,33 @@ class TestGeometryFactory(TestCase): self.assertIsNotNone(city.name, 'name is none') self.assertIsNotNone(city.country_code, 'country code is none') + def test_city_serialize(self): + city = self._get_citygml() + self.assertIsNotNone(city.city_objects, 'city_objects is none') + for building in city.buildings: + self.assertIsNotNone(city.city_object(building.name), 'city_object return none') + self.assertIsNotNone(city.srs_name, 'srs_name is none') + self.assertIsNotNone(city.lower_corner, 'lower_corner is none') + self.assertIsNotNone(city.upper_corner, 'upper_corner is none') + self.assertIsNotNone(city.name, 'name is none') + self.assertIsNotNone(city.country_code, 'country code is none') + + with open(self._pickle_file, 'wb') as f: + pickle.dump(city, f) + + def test_city_deserialize(self): + with open(self._pickle_file, 'rb') as f: + city = pickle.load(f) + print(f'city with {len(city.buildings)} buildings') + for building in city.buildings: + self.assertIsNotNone(city.city_object(building.name), 'city_object return none') + print(building.name) + self.assertIsNotNone(city.srs_name, 'srs_name is none') + self.assertIsNotNone(city.lower_corner, 'lower_corner is none') + self.assertIsNotNone(city.upper_corner, 'upper_corner is none') + self.assertIsNotNone(city.name, 'name is none') + self.assertIsNotNone(city.country_code, 'country code is none') + def test_citygml_buildings(self): """ Test city objects in the city