Skip to content

Commit

Permalink
test get_or_create_code
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Dec 1, 2024
1 parent bac8f00 commit 1c6d77a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def fixture_localhost(aiida_localhost):
def add_code(fixture_localhost):
from aiida.orm import InstalledCode

code = InstalledCode(computer=fixture_localhost, filepath_executable="/bin/bash")
code = InstalledCode(
label="add", computer=fixture_localhost, filepath_executable="/bin/bash"
)
code.store()
return code

Expand Down
22 changes: 22 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,25 @@ def test_validate_task_inout_dict_with_extra_keys():
]
result = validate_task_inout(input_list, "input")
assert result == input_list


def test_get_or_create_code(fixture_localhost, add_code):
from aiida_workgraph.utils import get_or_create_code
from aiida.orm import Code

# use already created code
code = get_or_create_code(
computer="localhost",
code_label="add",
code_path="/bin/bash",
prepend_text='echo "Hello, World!"',
)
assert code.uuid == add_code.uuid
# create a new code
code = get_or_create_code(
computer="localhost",
code_label="test_code",
code_path="/bin/bash",
prepend_text='echo "Hello, World!"',
)
assert isinstance(code, Code)

0 comments on commit 1c6d77a

Please sign in to comment.