Skip to content

Commit bfeb069

Browse files
committed
feat(input_file): added tests
1 parent d3704c3 commit bfeb069

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_utils_functions.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Third party imports
66
import flask
7+
import shutil
78

89
# Local application imports
910
from src.opengeodeweb_back import geode_functions, utils_functions
@@ -71,6 +72,44 @@ def test_handle_exception(client):
7172
assert type(data["code"]) is int
7273

7374

75+
def test_create_unique_data_folder():
76+
base_data_folder = "./tests/data"
77+
generated_id, data_path = utils_functions.create_unique_data_folder(base_data_folder)
78+
assert isinstance(generated_id, str)
79+
assert re.fullmatch(r"[0-9a-f]{32}", generated_id), "ID should be 32 hex characters"
80+
assert os.path.exists(data_path)
81+
assert data_path.startswith(base_data_folder)
82+
assert generated_id in data_path
83+
shutil.rmtree(data_path, ignore_errors=True)
84+
assert not os.path.exists(data_path)
85+
86+
87+
88+
def test_save_all_viewables_and_return_info(client):
89+
app = client.application
90+
with app.app_context():
91+
geode_object = "BRep"
92+
data = geode_functions.load(geode_object, "./tests/data/test.og_brep")
93+
generated_id, data_path = utils_functions.create_unique_data_folder(
94+
flask.current_app.config["DATA_FOLDER_PATH"]
95+
)
96+
additional_files = ["additional_file.txt"]
97+
98+
result = utils_functions.save_all_viewables_and_return_info(
99+
geode_object, data, generated_id, data_path, additional_files
100+
)
101+
102+
assert isinstance(result, dict)
103+
assert result["name"] == data.name()
104+
assert result["native_file_name"].startswith("native.")
105+
assert result["viewable_file_name"].endswith(".vtm")
106+
assert re.match(r"[0-9a-f]{32}", result["id"])
107+
assert isinstance(result["object_type"], str)
108+
assert isinstance(result["binary_light_viewable"], str)
109+
assert result["geode_object"] == geode_object
110+
assert result["input_files"] == additional_files
111+
112+
74113
def test_generate_native_viewable_and_light_viewable_from_object(client):
75114
app = client.application
76115
with app.app_context():

0 commit comments

Comments
 (0)