Skip to content

Commit

Permalink
Update tests to be used with aiida-optimade
Browse files Browse the repository at this point in the history
Removed several test files that are not relevant for aiida-optimade.
Updated transformer tests to be applicable with AiidaTransformer.
Added an update of package version to invoke task for
/tests/test_config.json.

Note: Keeping test_middleware.py for now, since a new middleware may be
added in aiidateam#72.
  • Loading branch information
CasperWA committed May 4, 2020
1 parent abc5db4 commit 8879ae1
Show file tree
Hide file tree
Showing 16 changed files with 434 additions and 1,177 deletions.
8 changes: 8 additions & 0 deletions aiida_optimade/transformers/aiida.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ def value_list(self, args):
"""value_list: [ OPERATOR ] value ( "," [ OPERATOR ] value )*"""
values = []
for value in args:
if value in self.reversed_operator_map:
# value is OPERATOR
# This is currently not supported
raise NotImplementedError(
f"OPERATOR {value} inside value_list {args} has not been "
"implemented."
)

try:
value = float(value)
except ValueError:
Expand Down
3 changes: 3 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def setver(_, patch=False, new_ver=""):
"aiida_optimade/config.json",
('"version": ([^,]+),', f'"version": "{new_ver}",'),
)
update_file(
"tests/test_config.json", ('"version": ([^,]+),', f'"version": "{new_ver}",'),
)

print("Bumped version to {}".format(new_ver))

Expand Down
32 changes: 0 additions & 32 deletions tests/config.json

This file was deleted.

16 changes: 14 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,17 @@

def pytest_configure(config):
"""Method that runs before pytest collects tests so no modules are imported"""
config_file = Path(__file__).parent.parent.joinpath("aiida_optimade/config.json")
os.environ["OPTIMADE_CONFIG_FILE"] = str(config_file)
set_config_file()
load_aiida_profile()


def set_config_file():
"""Set config file environment variable pointing to `/tests/test_config.json`"""
cwd = Path(__file__).parent.resolve()
os.environ["OPTIMADE_CONFIG_FILE"] = str(cwd.joinpath("test_config.json"))


def load_aiida_profile():
"""Load AiiDA profile"""
if os.getenv("AIIDA_PROFILE", None) is None:
os.environ["AIIDA_PROFILE"] = "optimade_sqla"
Loading

0 comments on commit 8879ae1

Please sign in to comment.