Skip to content

Commit 39ca09a

Browse files
committed
rechange some tests & functions
1 parent 3aeb276 commit 39ca09a

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def geode_object_output_extensions(
5555
geode_object: GeodeObject,
5656
) -> dict[GeodeObjectType, dict[str, bool]]:
5757
results: dict[GeodeObjectType, dict[str, bool]] = {}
58-
current_type = geode_object.geode_object_type()
59-
for mixin_geode_object in geode_objects[current_type].__mro__:
58+
for mixin_geode_object in geode_objects[geode_object.geode_object_type()].__mro__:
6059
output_extensions_method = getattr(
6160
mixin_geode_object, "output_extensions", None
6261
)
@@ -67,16 +66,11 @@ def geode_object_output_extensions(
6766
continue
6867
object_output_extensions: dict[str, bool] = {}
6968
is_saveable_method = getattr(mixin_geode_object, "is_saveable")
70-
target_type = None
71-
if hasattr(mixin_geode_object, "geode_object_type"):
72-
target_type = mixin_geode_object.geode_object_type()
73-
if target_type and target_type != current_type:
74-
continue
7569
for output_extension in output_extensions:
7670
bool_is_saveable = is_saveable_method(
7771
geode_object, f"test.{output_extension}"
7872
)
7973
object_output_extensions[output_extension] = bool_is_saveable
80-
if target_type:
81-
results[target_type] = object_output_extensions
82-
return results
74+
if hasattr(mixin_geode_object, "geode_object_type"):
75+
results[mixin_geode_object.geode_object_type()] = object_output_extensions
76+
return results

src/opengeodeweb_back/utils_functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def save_all_viewables_and_return_info(
212212
data.native_file = os.path.basename(native_files[0])
213213
data.viewable_file = os.path.basename(viewable_path)
214214
data.light_viewable_file = os.path.basename(light_path)
215+
216+
if not data.input_file:
217+
data.input_file = data.native_file
218+
215219
assert data.native_file is not None
216220
assert data.viewable_file is not None
217221
assert data.light_viewable_file is not None
@@ -223,11 +227,10 @@ def save_all_viewables_and_return_info(
223227
"viewer_type": data.viewer_object,
224228
"binary_light_viewable": binary_light_viewable.decode("utf-8"),
225229
"geode_object_type": data.geode_object,
226-
"input_file": data.input_file or "",
230+
"input_file": data.input_file or "",
227231
"additional_files": data.additional_files or [],
228232
}
229233

230-
231234
def generate_native_viewable_and_light_viewable_from_object(
232235
geode_object: GeodeObject,
233236
) -> dict[str, str | list[str]]:

tests/test_utils_functions.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,29 @@ def test_generate_native_viewable_and_light_viewable_from_object(
183183
)
184184
)
185185

186-
assert isinstance(result, dict)
187-
assert isinstance(result["native_file"], str)
188-
assert result["native_file"].startswith("native.")
189-
assert isinstance(result["viewable_file"], str)
190-
assert result["viewable_file"].endswith(".vtm")
191-
assert isinstance(result["id"], str)
192-
assert re.match(r"[0-9a-f]{32}", result["id"])
193-
assert isinstance(result["viewer_type"], str)
194-
assert isinstance(result["binary_light_viewable"], str)
195-
assert result["input_file"] == ""
186+
assert isinstance(result, dict)
187+
assert isinstance(result["native_file"], str)
188+
assert result["native_file"].startswith("native.")
189+
assert isinstance(result["viewable_file"], str)
190+
assert result["viewable_file"].endswith(".vtm")
191+
assert isinstance(result["id"], str)
192+
assert re.match(r"[0-9a-f]{32}", result["id"])
193+
assert isinstance(result["viewer_type"], str)
194+
assert isinstance(result["binary_light_viewable"], str)
195+
assert result["binary_light_viewable"].startswith('<?xml version="1.0"?>')
196+
197+
assert result["input_file"] == result["native_file"]
198+
199+
data = Data.get(result["id"])
200+
assert data is not None
201+
assert data.input_file == data.native_file
202+
assert data.light_viewable_file is not None
203+
assert data.light_viewable_file.endswith('.vtp')
204+
205+
data_path = os.path.join(app.config["DATA_FOLDER_PATH"], result["id"])
206+
assert os.path.exists(os.path.join(data_path, result["native_file"]))
207+
assert os.path.exists(os.path.join(data_path, result["viewable_file"]))
208+
assert os.path.exists(os.path.join(data_path, data.light_viewable_file))
196209

197210

198211
def test_generate_native_viewable_and_light_viewable_from_file(

0 commit comments

Comments
 (0)