Skip to content

Commit

Permalink
Test sorting by qcarchive_id
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Dec 5, 2023
1 parent 69b8ec2 commit 3b93dcb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ibstore/_tests/unit_tests/test_store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import json
import random
import tempfile

import numpy
import pytest
from openff.qcsubmit.results import OptimizationResultCollection
from openff.utilities import get_data_file_path, temporary_cd

from ibstore._store import MoleculeStore
Expand Down Expand Up @@ -57,6 +60,28 @@ def test_get_molecule_id_by_qcarchive_id(small_store):
assert small_store.get_molecule_id_by_qcarchive_id(qcarchive_id) == molecule_id


def test_molecules_sorted_by_qcarchive_id():
raw_ch = json.load(
open(get_data_file_path("_tests/data/01-processed-qm-ch.json", "ibstore")),
)

random.shuffle(raw_ch["entries"]["https://api.qcarchive.molssi.org:443/"])

with tempfile.NamedTemporaryFile(mode="w+") as file:
json.dump(raw_ch, file)
file.flush()

store = MoleculeStore.from_qcsubmit_collection(
OptimizationResultCollection.parse_file(file.name),
database_name=tempfile.NamedTemporaryFile(suffix=".sqlite").name,
)

qcarchive_ids = store.get_qcarchive_ids_by_molecule_id(40)

for index, id in enumerate(qcarchive_ids[:-1]):
assert id < qcarchive_ids[index + 1]


def test_get_conformers(small_store):
force_field = "openff-2.0.0"
molecule_id = 40
Expand Down

0 comments on commit 3b93dcb

Please sign in to comment.