From 5e5b0cede359c58b91a232608e6b869265b272fe Mon Sep 17 00:00:00 2001 From: Alex Loembe Date: Wed, 22 May 2024 08:38:03 -0400 Subject: [PATCH] test with more logs --- python/docker-compose.yaml | 1 + python/nistoar/midas/dbio/mongo.py | 1 + python/tests/nistoar/midas/dbio/test.json | 46 +++++++++++++++++++ python/tests/nistoar/midas/dbio/test_mongo.py | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 python/tests/nistoar/midas/dbio/test.json diff --git a/python/docker-compose.yaml b/python/docker-compose.yaml index 6317709d..6770bf7e 100644 --- a/python/docker-compose.yaml +++ b/python/docker-compose.yaml @@ -18,6 +18,7 @@ services: - type: volume source: MONGO_CONFIG target: /data/configdb + mongo-express: image: mongo-express:latest container_name: mongo-express diff --git a/python/nistoar/midas/dbio/mongo.py b/python/nistoar/midas/dbio/mongo.py index d6cc7c28..35cf0e6a 100644 --- a/python/nistoar/midas/dbio/mongo.py +++ b/python/nistoar/midas/dbio/mongo.py @@ -207,6 +207,7 @@ def select_records(self, perm: base.Permissions=base.ACLs.OWN, **cnsts) -> Itera def adv_select_records(self, filter: dict, perm: base.Permissions=base.ACLs.OWN) -> Iterator[base.ProjectRecord]: + print(filter) if base.DBClient.check_query_structure(filter): if isinstance(perm, str): perm = [perm] diff --git a/python/tests/nistoar/midas/dbio/test.json b/python/tests/nistoar/midas/dbio/test.json new file mode 100644 index 00000000..2b1c5c1e --- /dev/null +++ b/python/tests/nistoar/midas/dbio/test.json @@ -0,0 +1,46 @@ +{ + "$and":[ + { + "status.state":"edit" + }, + { + "name":"test3" + }, + { + "$or":[ + { + "acls.delete":{ + "$in":[ + "nist0:ava1", + "grp0:public" + ] + } + }, + { + "acls.write":{ + "$in":[ + "nist0:ava1", + "grp0:public" + ] + } + }, + { + "acls.admin":{ + "$in":[ + "nist0:ava1", + "grp0:public" + ] + } + }, + { + "acls.read":{ + "$in":[ + "nist0:ava1", + "grp0:public" + ] + } + } + ] + } + ] + } \ No newline at end of file diff --git a/python/tests/nistoar/midas/dbio/test_mongo.py b/python/tests/nistoar/midas/dbio/test_mongo.py index 294b12e1..74ff7cef 100644 --- a/python/tests/nistoar/midas/dbio/test_mongo.py +++ b/python/tests/nistoar/midas/dbio/test_mongo.py @@ -316,7 +316,6 @@ def test_select_records(self): def test_adv_select_records(self): # inject some data into the database - id = "pdr0:0002" rec = base.ProjectRecord( base.DMP_PROJECTS, {"id": id, "name": "test 1", "deactivated": "null", "status": { @@ -377,6 +376,7 @@ def test_adv_select_records(self): self.assertEqual(recs[1].id, "pdr0:0003") recs = list(self.cli.adv_select_records(constraint_and)) + print(constraint_and) self.assertEqual(len(recs), 1) self.assertEqual(recs[0].id, "pdr0:0003") recs = list(self.cli.adv_select_records(constraint_andor, base.ACLs.READ))