Skip to content

Commit

Permalink
Updated new dlite-parse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-friis committed Jun 25, 2024
1 parent db8c212 commit d92949c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
67 changes: 33 additions & 34 deletions tests/entities/Molecule.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
da31ff66-98af-590c-855d-386c63617755:
da31ff66-98af-590c-855d-386c63617755:
uuid: da31ff66-98af-590c-855d-386c63617755
uri: http://onto-ns.com/meta/0.1/Molecule
meta: http://onto-ns.com/meta/0.3/EntitySchema
description: A minimal description of a molecules
dimensions:
natoms: Number of atoms
ncoords: Number coordinates. Always 3
properties:
name:
type: string
description: Name of the molecule.
positions:
type: float64
shape:
- natoms
- ncoords
unit: "\xC5ngstr\xF6m"
description: Atomic positions in Cartesian coordinates.
symbols:
type: string
shape:
- natoms
description: Chemical symbols.
masses:
type: float64
shape:
- natoms
unit: u
description: Atomic masses.
groundstate_energy:
type: float64
unit: eV
description: Molecule ground state energy.
uuid: da31ff66-98af-590c-855d-386c63617755
uri: http://onto-ns.com/meta/0.1/Molecule
meta: http://onto-ns.com/meta/0.3/EntitySchema
description: A minimal description of a molecules
dimensions:
natoms: Number of atoms
ncoords: Number coordinates. Always 3
properties:
name:
type: string
description: Name of the molecule.
positions:
type: float64
shape:
- natoms
- ncoords
unit: "\xC5ngstr\xF6m"
description: Atomic positions in Cartesian coordinates.
symbols:
type: string
shape:
- natoms
description: Chemical symbols.
masses:
type: float64
shape:
- natoms
unit: u
description: Atomic masses.
groundstate_energy:
type: float64
unit: eV
description: Molecule ground state energy.
1 change: 1 addition & 0 deletions tests/strategies/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
entitydir = testdir / "entities"
inputdir = testdir / "input"
outputdir = testdir / "output"
staticdir = testdir / "static"


# Add utils to sys path
Expand Down
26 changes: 14 additions & 12 deletions tests/strategies/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
from oteapi_dlite.models import DLiteSessionUpdate


def test_parse_no_options(
static_files: "Path",
) -> None:
# if True:
def test_parse_no_options() -> None:
"""Test the dlite-parse strategy."""

import dlite
from oteapi.datacache import DataCache
from paths import staticdir

from oteapi_dlite.strategies.parse import DLiteParseStrategy

sample_file = static_files / "molecule.json"
sample_file = staticdir / "molecule.json"

cache = DataCache()

Expand All @@ -45,23 +45,25 @@ def test_parse_no_options(
assert "collection_id" in output
assert output.collection_id == coll.uuid

# How to reach the instance if we do not have a label?
# coll2: dlite.Collection = dlite.get_instance(session["collection_id"])
# inst: dlite.Instance = coll2.get("instance")
# assert ...
# Get all instances of given metaid (there should only be one instance)
metaid = "http://onto-ns.com/meta/0.1/Molecule"
instances = list(coll.get_instances(metaid=metaid))
assert len(instances) == 1
(inst,) = instances
assert inst.meta.uri == metaid


def test_parse_label(
static_files: "Path",
) -> None:
# if True:
def test_parse_label() -> None:
"""Test the dlite-parse strategy."""

import dlite
from oteapi.datacache import DataCache
from paths import staticdir

from oteapi_dlite.strategies.parse import DLiteParseStrategy

sample_file = static_files / "molecule.json"
sample_file = staticdir / "molecule.json"

cache = DataCache()

Expand Down

0 comments on commit d92949c

Please sign in to comment.