Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienChampagnol committed Dec 6, 2023
1 parent 27ef421 commit 78fefe1
Showing 1 changed file with 53 additions and 37 deletions.
90 changes: 53 additions & 37 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def test_missing_files():
assert type(additional_files) is list


def test_is_loadable():
for geode_object, value in geode_objects.geode_objects_dict().items():
input_extensions = geode_functions.geode_object_input_extensions(geode_object)
for input_extension in input_extensions:
file_absolute_path = os.path.abspath(f"tests/data/test.{input_extension}")
is_loadable = geode_functions.is_loadable(geode_object, file_absolute_path)
assert type(is_loadable) is bool


def test_load():
for geode_object, value in geode_objects.geode_objects_dict().items():
print(f"\n{geode_object=}")
Expand All @@ -70,43 +79,48 @@ def test_load():
file_apsolute_path = os.path.abspath(
f"tests/data/test.{input_extension}"
)

data = geode_functions.load(geode_object, file_apsolute_path)
for (
geode_object_and_output_extensions
) in geode_functions.geode_objects_output_extensions(
geode_object, data
):
output_geode_object = geode_object_and_output_extensions[
"geode_object"
]
print(f"\t\t{output_geode_object=}")
output_extensions = geode_functions.geode_object_output_extensions(
geode_object
)

for output_extension in output_extensions:
print(f"\t\t\t{output_extension=}")
uu_id = str(uuid.uuid4()).replace("-", "")
filename = f"{uu_id}.{output_extension}"
if geode_functions.is_saveable(geode_object, data, filename):
file_path = geode_functions.save(
geode_object,
data,
os.path.abspath(f"output"),
f"{uu_id}.{output_extension}",
)

if "save_viewable" in value:
uu_id = str(uuid.uuid4()).replace("-", "")
viewable_file_path = geode_functions.save_viewable(
is_loadable = geode_functions.is_loadable(
geode_object, file_apsolute_path
)
if is_loadable:
data = geode_functions.load(geode_object, file_apsolute_path)
for (
geode_object_and_output_extensions
) in geode_functions.geode_objects_output_extensions(
geode_object, data
):
output_geode_object = geode_object_and_output_extensions[
"geode_object"
]
print(f"\t\t{output_geode_object=}")
output_extensions = (
geode_functions.geode_object_output_extensions(geode_object)
)

for output_extension in output_extensions:
print(f"\t\t\t{output_extension=}")
uu_id = str(uuid.uuid4()).replace("-", "")
filename = f"{uu_id}.{output_extension}"
if geode_functions.is_saveable(
geode_object, data, filename
):
saved_files = geode_functions.save(
geode_object,
data,
os.path.abspath(f"output"),
uu_id,
f"{uu_id}.{output_extension}",
)

os.remove(viewable_file_path)
if "save_viewable" in value:
uu_id = str(uuid.uuid4()).replace("-", "")
viewable_file_path = geode_functions.save_viewable(
geode_object,
data,
os.path.abspath(f"output"),
uu_id,
)

os.remove(viewable_file_path)


def test_is_model():
Expand Down Expand Up @@ -206,14 +220,16 @@ def test_geode_objects_output_extensions():
data = geode_functions.load(
geode_object, f"tests/data/test.{input_extension}"
)
geode_objects_and_output_extensions_list = (
geode_functions.geode_objects_output_extensions(geode_object, data)
geode_objects_and_output_extensions = (
geode_functions.geode_objects_and_output_extensions(
geode_object, data
)
)
print(f"{geode_objects_and_output_extensions_list=}")
assert type(geode_objects_and_output_extensions_list) is list
print(f"{geode_objects_and_output_extensions=}")
assert type(geode_objects_and_output_extensions) is dict
for (
geode_object_and_output_extensions
) in geode_objects_and_output_extensions_list:
) in geode_objects_and_output_extensions.values():
print(f"{geode_object_and_output_extensions=}")
assert type(geode_object_and_output_extensions) is dict
assert "geode_object" in geode_object_and_output_extensions
Expand Down

0 comments on commit 78fefe1

Please sign in to comment.