1- import uuid
2-
31import pytest
42from dcoraid .dbmodel import meta_cache_sqlite
53
6-
7- def make_example_ds_dict ():
8- org_id = f"{ uuid .uuid4 ()} "
9- ds_id = f"{ uuid .uuid4 ()} "
10- user_id = f"{ uuid .uuid4 ()} "
11- return {"authors" : "John Doe" ,
12- "creator_user_id" : f"{ user_id } " ,
13- "doi" : "" ,
14- "id" : f"{ ds_id } " ,
15- "isopen" : True ,
16- "license_id" : "CC-BY-SA-4.0" ,
17- "license_title" : "Creative Commons Attribution Share-Alike 4.0" ,
18- "license_url" : "https://creativecommons.org/licenses/by-sa/4.0/" ,
19- "metadata_created" : "2025-09-11T08:09:52.947634" ,
20- "metadata_modified" : "2025-09-11T08:10:13.882541" ,
21- "name" : "an-example-dataset" ,
22- "notes" : "A description" ,
23- "num_resources" : 1 , "num_tags" : 2 ,
24- "organization" : {
25- "id" : f"{ org_id } " ,
26- "name" : "dcoraid-circle" , "title" : "" ,
27- "type" : "organization" ,
28- "description" : "" , "image_url" : "" ,
29- "created" : "2020-09-23T09:50:44.826360" ,
30- "is_organization" : True ,
31- "approval_status" : "approved" ,
32- "state" : "active" },
33- "owner_org" : f"{ org_id } " ,
34- "private" : True , "references" : "" ,
35- "state" : "active" , "title" : "Dataset Title" ,
36- "type" : "dataset" , "resources" : [
37- {"cache_last_updated" : None , "cache_url" : None ,
38- "created" : "2025-09-18T08:10:06.286171" ,
39- "dc:experiment:date" : "2018-12-11" ,
40- "dc:experiment:event count" : 47 , "dc:experiment:run index" : 1 ,
41- "url_type" : "s3_upload" }],
42- "tags" : [{"display_name" : "GFP" ,
43- "id" : "5b5e7553-49a0-49b4-b342-28b8384800c0" ,
44- "name" : "GFP" ,
45- "state" : "active" ,
46- "vocabulary_id" : None },
47- {"display_name" : "HL60" ,
48- "id" : "f4e18050-d2dc-4fd2-93d4-015666f0e066" ,
49- "name" : "HL60" ,
50- "state" : "active" ,
51- "vocabulary_id" : None }],
52- "groups" : [],
53- "relationships_as_subject" : [],
54- "relationships_as_object" : []}
4+ from .common import make_dataset_dict_full_fake
555
566
577def test_create_write_read (tmp_path ):
588 db_path = tmp_path / "database.db"
599
6010 with meta_cache_sqlite .SQLiteKeyJSONDatabase (db_path ) as db :
61- ds_dict = make_example_ds_dict ()
11+ ds_dict = make_dataset_dict_full_fake ()
6212 db [ds_dict ["id" ]] = ds_dict
6313 ds_dict2 = db [ds_dict ["id" ]]
6414 assert ds_dict == ds_dict2
@@ -69,16 +19,15 @@ def test_create_write_read(tmp_path):
6919 assert ds_dict == ds_dict3
7020
7121
72-
7322def test_create_multiple_and_iter (tmp_path ):
7423 db_path = tmp_path / "database.db"
7524
7625 with meta_cache_sqlite .SQLiteKeyJSONDatabase (db_path ) as db :
77- ds_dict = make_example_ds_dict ()
26+ ds_dict = make_dataset_dict_full_fake ()
7827 db [ds_dict ["id" ]] = ds_dict
7928
8029 for ii in range (10 ):
81- dsi = make_example_ds_dict ()
30+ dsi = make_dataset_dict_full_fake ()
8231 db [dsi ["id" ]] = dsi
8332
8433 assert db [ds_dict ["id" ]] == ds_dict
@@ -94,7 +43,7 @@ def test_pop(tmp_path):
9443 db_path = tmp_path / "database.db"
9544
9645 with meta_cache_sqlite .SQLiteKeyJSONDatabase (db_path ) as db :
97- ds_dict = make_example_ds_dict ()
46+ ds_dict = make_dataset_dict_full_fake ()
9847 db [ds_dict ["id" ]] = ds_dict
9948 ds_dict2 = db [ds_dict ["id" ]]
10049 assert ds_dict == ds_dict2
0 commit comments