Skip to content

Commit

Permalink
test(typing path): Added tests for the typing path checkers.
Browse files Browse the repository at this point in the history
  • Loading branch information
built-test authored and built-tools committed Dec 8, 2021
1 parent 0993040 commit 4659c34
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions tests/typing_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
from honeybee_radiance_command._typing import normpath
from honeybee_radiance_command._typing import normpath, path_checker, \
path_checker_multiple
import pytest

test_path1 = 'tests/assets/receiver.rad'
test_path2 = 'tests/assets/dir with space/Jan 1 12.sky'

def test_normpath():
test_path1 = 'tests/assets/receiver.rad'
test_path2 = 'tests/assets/dir with space/Jan 1 12.sky'

def test_normpath():
normpath_1 = normpath(test_path1)
normpath_2 = normpath(test_path2)

Expand All @@ -22,3 +23,38 @@ def test_normpath():
assert os.path.exists(normpath_1)
with pytest.raises(AssertionError):
assert os.path.exists(normpath_2)


def test_path_checker():
pth1 = path_checker(test_path1)

pth2 = path_checker(test_path1, extn_list=['.rad'])

with pytest.raises(ValueError):
pth2 = path_checker(test_path2, extn_list=['.rad', '.mat'])


def test_path_checker_multiple():
pth_list = path_checker_multiple([test_path1, test_path2])
if os.name == 'nt':
assert pth_list == ['tests/assets/receiver.rad',
'"tests/assets/dir with space/Jan 1 12.sky"']
else:
assert pth_list == ['tests/assets/receiver.rad',
"'tests/assets/dir with space/Jan 1 12.sky'"]

pth_list_str = path_checker_multiple([test_path1, test_path2],
outputs_as_string=True)
if os.name == 'nt':
assert pth_list_str == r'tests/assets/receiver.rad ' \
r'"tests/assets/dir with space/Jan 1 12.sky"'
else:
assert pth_list_str == r'tests/assets/receiver.rad ' \
r"'tests/assets/dir with space/Jan 1 12.sky'"

pth_list = path_checker_multiple([test_path1, test_path2],
extn_list=('.rad', '.sky'))

with pytest.raises(ValueError):
pth_list = path_checker_multiple([test_path1, test_path2],
extn_list=('.rad', '.mat'))

0 comments on commit 4659c34

Please sign in to comment.