Skip to content

Commit

Permalink
Add some workchain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kmlefran committed Jan 23, 2024
1 parent 2e62c96 commit a0789c4
Show file tree
Hide file tree
Showing 17 changed files with 376,356 additions and 5 deletions.
6 changes: 3 additions & 3 deletions aiida_aimall/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ def parse(self, **kwargs):
self.logger.error(
f"Found files '{files_retrieved}', expected to find '{files_expected}'"
)
# return self.exit_codes.ERROR_MISSING_OUTPUT_FILES
return
return self.exit_codes.ERROR_MISSING_OUTPUT_FILES
# return

# parse output file
self.logger.info(f"Parsing '{output_filename}'")
Expand Down Expand Up @@ -356,7 +356,7 @@ def parse(self, **kwargs):
)
self.outputs.output_parameters = Dict(out_dict)

return # ExitCode(0)
return ExitCode(0)

def _parse_graph_descriptor(self, out_dict):
"""Get atomic, BCP, and VSCC properties of atom 1"""
Expand Down
25 changes: 23 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections.abc import Mapping

import pytest
from aiida.orm import SinglefileData, Str
from aiida.orm import FolderData, SinglefileData, Str

from aiida_aimall.data import AimqbParameters

Expand Down Expand Up @@ -120,6 +120,28 @@ def _generate_parser(entry_point_name):
return _generate_parser


@pytest.fixture
def generate_workchain_folderdata():
"""Generate FolderData of an AIM calculation"""

def _generate_workchain_folderdata(
entry_point_name="base",
test_name=None,
):
filepath_folder = None

if test_name is not None:
basepath = os.path.dirname(os.path.abspath(__file__))
filename = os.path.join(entry_point_name, test_name)
filepath_folder = os.path.join(basepath, "workchains", "fixtures", filename)
if filepath_folder:
retrieved = FolderData()
retrieved.base.repository.put_object_from_tree(filepath_folder)
return retrieved

return _generate_workchain_folderdata


@pytest.fixture
def generate_calc_job_node(fixture_localhost):
"""Generate a mock `CalcJobNode` for testing parsers"""
Expand Down Expand Up @@ -225,7 +247,6 @@ def _generate_calc_job_node( # pylint:disable=too-many-arguments
if filepath_folder:
retrieved = orm.FolderData()
retrieved.base.repository.put_object_from_tree(filepath_folder)
print(retrieved.list_object_names())
# Remove files that are supposed to be only present in the retrieved temporary folder
if retrieve_temporary:
for filename in filenames:
Expand Down
28 changes: 28 additions & 0 deletions tests/parsers/test_aimqbgroupparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,31 @@ def test_aimqb_parser_group( # pylint:disable=too-many-arguments
assert "cc_properties" in results_dict
assert "graph_descriptor" in results_dict
assert "group_descriptor" in results_dict


def test_group_empty_outfolder_returns_exitcode( # pylint:disable=too-many-arguments
fixture_localhost,
generate_calc_job_node,
generate_parser,
generate_aimqb_group_inputs,
fixture_code,
filepath_tests,
):
"""Test an aimqb calculation"""

name = "empty"
entry_point_calc_job = "aimall.aimqb"
entry_point_parser = "aimall.group"
node = generate_calc_job_node(
entry_point_calc_job,
fixture_localhost,
name,
generate_aimqb_group_inputs(fixture_code, filepath_tests),
)
parser = generate_parser(entry_point_parser)
_, calcfunction = parser.parse_from_node(node, store_provenance=False)

assert (
calcfunction.exit_status
== node.process_class.exit_codes.ERROR_MISSING_OUTPUT_FILES.status
)
1,073 changes: 1,073 additions & 0 deletions tests/workchains/fixtures/aimall.aimreor/default/aiida.sum

Large diffs are not rendered by default.

1,461 changes: 1,461 additions & 0 deletions tests/workchains/fixtures/aimall.aimreor/default/aiida_atomicfiles/h2.agpviz

Large diffs are not rendered by default.

91,500 changes: 91,500 additions & 0 deletions tests/workchains/fixtures/aimall.aimreor/default/aiida_atomicfiles/h2.iasviz

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Title Card Required
H2
Auto
Critical Point Data
1 0 0
3.87827005269859E-19 1.15228936968740E+00 -6.69736533337040E-01 O1
0 0
Options
Integer 4
42 1
11 2
49 1
52 1
Real 0
Loading

0 comments on commit a0789c4

Please sign in to comment.