diff --git a/src/gevopy/database.py b/src/gevopy/database.py index dd314be..3f7da45 100755 --- a/src/gevopy/database.py +++ b/src/gevopy/database.py @@ -409,8 +409,9 @@ def get_phenotypes(tx, ids): "WITH x, e, collect(y.id) as p " "RETURN x{.*, .score, experiment:e.name, parents:p } " ) - result = tx.run(query, phenotypes_ids=ids) - return [dict(record["x"]) for record in result] + result = [dict(r["x"]) for r in tx.run(query, phenotypes_ids=ids)] + result.sort(key=lambda r: ids.index(r['id'])) + return result @neo4j.unit_of_work(timeout=config['timeout']) diff --git a/tests/test_utilities/test_database.py b/tests/test_utilities/test_database.py index 7dedb19..ba6b430 100755 --- a/tests/test_utilities/test_database.py +++ b/tests/test_utilities/test_database.py @@ -3,7 +3,7 @@ import uuid -from pytest import fixture +from pytest import fixture, mark @fixture(scope="module", autouse=True) @@ -52,8 +52,9 @@ def ids(population): return [str(ph.id) for ph in population] +@mark.parametrize("db_interface", ["Neo4jInterface"], indirect=True) def test_rwd_phenotypes(session, phenotypes, ids): """Test write, read and delete of phenotypes in db""" assert ids == session.add_phenotypes(phenotypes) assert phenotypes == session.get_phenotypes(ids) - assert ids == session.del_phenotypes(ids) + assert all([id in ids for id in session.del_phenotypes(ids)])