Skip to content
Snippets Groups Projects
Commit cbf3d0b0 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

add test for auto_detect_modelpath with mixed case filenames

parent d4a75628
No related branches found
No related tags found
No related merge requests found
......@@ -105,10 +105,17 @@ class HTCFile(HTCContents, HTCDefaults, HTCExtensions):
import numpy as np
input_files = HTCFile(self.filename, 'unknown').input_files()
rel_input_files = [f for f in input_files if not os.path.isabs(f)]
found = ([np.sum([os.path.isfile(os.path.join(os.path.dirname(self.filename), "../" * i, f))
def isfile_case_insensitive(f):
try:
unix_path_old(f)
return True
except IOError:
return False
found = ([np.sum([isfile_case_insensitive(os.path.join(os.path.dirname(self.filename), "../" * i, f))
for f in rel_input_files]) for i in range(4)])
# for f in self.input_files():
# print (os.path.isfile(os.path.join(os.path.dirname(self.filename), "../",f)), f)
# print(os.path.isfile(os.path.join(os.path.dirname(self.filename), "../", f)), f)
if max(found) > 0:
relpath = "../" * np.argmax(found)
return os.path.abspath(os.path.join(os.path.dirname(self.filename), relpath))
......
......@@ -300,6 +300,10 @@ end turb_export;"""
htcfile.filename)).replace("\\", "/"), "../..")
self.assertRaisesRegex(ValueError, "Modelpath cannot be autodetected", HTCFile, self.testfilepath + "test2.htc")
def test_htc_model_autodetect_upper_case_files(self):
htcfile = HTCFile(self.testfilepath + "../simulation_setup/DTU10MWRef6.0/htc/DTU_10MW_RWT.htc")
self.assertEqual(os.path.relpath(htcfile.modelpath, os.path.dirname(htcfile.filename)), "..")
def test_open_eq_save(self):
HTCFile(self.testfilepath + "test3.htc", "../").save(self.testfilepath + "tmp.htc")
htcfile = HTCFile(self.testfilepath + "tmp.htc", "../")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment