Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloge committed Feb 22, 2022
1 parent d0c749a commit 77a5709
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions toolium/test/utils/test_dataset_map_param.py
Expand Up @@ -38,19 +38,23 @@ def test_a_file_param():
"""
Verification of a mapped parameter as FILE
"""
result = map_param("[FILE:toolium/test/resources/document.txt]")
expected = "Document used to verify functionalities in MSS "
assert expected == result
set_file_path('toolium/test/resources/')
result = map_param("[FILE:document.txt]")
expected = "Document used to verify functionalities in MSS "
assert expected == result


def test_a_base64_param():
"""
Verification of a mapped parameter as BASE64
"""
result = map_param("[BASE64:toolium/test/resources/document.txt]")
expected = "RG9jdW1lbnQgdXNlZCB0byB2ZXJpZnkgZnVuY3Rpb25hbGl0aWVzIGluIE1TUyA="
assert expected == result
set_base64_path('toolium/test/resources/')
result = map_param("[BASE64:document.txt]")
expected = "RG9jdW1lbnQgdXNlZCB0byB2ZXJpZnkgZnVuY3Rpb25hbGl0aWVzIGluIE1TUyA="
assert expected == result


Expand Down
12 changes: 6 additions & 6 deletions toolium/utils/dataset.py
Expand Up @@ -30,8 +30,8 @@
logger = logging.getLogger(__name__)

# Base path for BASE64 and FILE conversions
base_base64_path = 'resources/'
base_file_path = 'resources/'
base_base64_path = ''
base_file_path = ''


def replace_param(param, language='es', infer_param_type=True):
Expand Down Expand Up @@ -597,8 +597,8 @@ def get_file(file_path):
:param file path: file path using slash as separator (e.g. "resources/files/doc.txt")
:return: string with the file content
"""
file_path_parts = [os.getcwd()] + (base_file_path + file_path).split("/")
file_path = os.path.join(*file_path_parts)
file_path_parts = (base_file_path + file_path).split("/")
file_path = os.path.abspath(os.path.join(*file_path_parts))
if not os.path.exists(file_path):
raise Exception(f' ERROR - Cannot read file "{file_path}". Does not exist.')

Expand All @@ -614,8 +614,8 @@ def convert_file_to_base64(file_path):
:param file path: file path using slash as separator (e.g. "resources/files/doc.txt")
:return: string with the file content encoded in Base64
"""
file_path_parts = [os.getcwd()] + (base_base64_path + file_path).split("/")
file_path = os.path.join(*file_path_parts)
file_path_parts = (base_base64_path + file_path).split("/")
file_path = os.path.abspath(os.path.join(*file_path_parts))
if not os.path.exists(file_path):
raise Exception(f' ERROR - Cannot read file "{file_path}". Does not exist.')

Expand Down

0 comments on commit 77a5709

Please sign in to comment.