From 8fea115cb1e76710c10f2d06fca89f8a68ceab3f Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Tue, 22 Aug 2023 04:27:49 +0300 Subject: [PATCH] Final bit fixing tests --- qfieldsync/tests/test_export.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qfieldsync/tests/test_export.py b/qfieldsync/tests/test_export.py index 41f09816..fb6e6b1c 100644 --- a/qfieldsync/tests/test_export.py +++ b/qfieldsync/tests/test_export.py @@ -22,6 +22,7 @@ import shutil import tempfile from pathlib import Path +from typing import List from qgis.core import Qgis, QgsOfflineEditing, QgsProject from qgis.testing import start_app, unittest @@ -46,6 +47,9 @@ def tearDown(self): shutil.rmtree(self.source_dir) shutil.rmtree(self.target_dir) + def _path_contents(self, dir_path: Path) -> List[str]: + return list(map(lambda p: str(p.relative_to(dir_path)), dir_path.iterdir())) + @property def data_dir(self) -> Path: return Path(__file__).parent.joinpath("data") @@ -76,7 +80,7 @@ def test_copy(self): ) offline_converter.convert() - files = list(self.target_dir.iterdir()) + files = self._path_contents(self.target_dir) self.assertIn("project_qfield.qgs", files) self.assertIn("france_parts_shape.shp", files) @@ -84,11 +88,13 @@ def test_copy(self): self.assertIn("curved_polys.gpkg", files) self.assertIn("spatialite.db", files) - dcim_files = list(self.target_dir.joinpath("DCIM").iterdir()) + dcim_files = self._path_contents(self.target_dir.joinpath("DCIM")) self.assertIn("qfield-photo_1.jpg", dcim_files) self.assertIn("qfield-photo_2.jpg", dcim_files) self.assertIn("qfield-photo_3.jpg", dcim_files) - dcim_subfiles = list(self.target_dir.joinpath("DCIM", "subfolder").iterdir()) + dcim_subfiles = self._path_contents( + self.target_dir.joinpath("DCIM", "subfolder") + ) self.assertIn("qfield-photo_sub_1.jpg", dcim_subfiles) self.assertIn("qfield-photo_sub_2.jpg", dcim_subfiles) self.assertIn("qfield-photo_sub_3.jpg", dcim_subfiles)