Merge remote-tracking branch 'origin/master'

This commit is contained in:
pilar 2020-12-01 17:19:29 -05:00
commit 9a134e94c2

View File

@ -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