Skip to content

Commit

Permalink
cleanup of test data
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-TBT committed Mar 7, 2024
1 parent 579ce8e commit 51131d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ def project_structure(conn, timestamp, image_fixture, users_groups,
yield [project_info, dataset_info, image_info]
current_group = conn.getGroupFromContext().getId()
conn.SERVICE_OPTS.setOmeroGroup(-1)
for dname, did in dataset_info:
conn.deleteObjects("Dataset", [did], deleteAnns=True,
deleteChildren=True, wait=True)
for pname, pid in project_info:
conn.deleteObjects("Project", [pid], deleteAnns=True,
deleteChildren=True, wait=True)
Expand Down Expand Up @@ -584,6 +587,8 @@ def screen_structure(conn, timestamp, image_fixture):
conn.SERVICE_OPTS.setOmeroGroup(-1)
conn.deleteObjects("Screen", [screen_id], deleteAnns=True,
deleteChildren=True, wait=True)
conn.deleteObjects("Plate", [plate3_id], deleteAnns=True,
deleteChildren=True, wait=True)
conn.SERVICE_OPTS.setOmeroGroup(current_group)


Expand Down
19 changes: 19 additions & 0 deletions tests/test_ezimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
# Test imports


def test_cleanup(conn):
ids = ezomero.get_project_ids(conn)
if len(ids) > 0:
conn.deleteObjects("Project", ids, deleteChildren=True)
ids = ezomero.get_dataset_ids(conn)
if len(ids) > 0:
conn.deleteObjects("Dataset", ids, deleteChildren=True)
ids = ezomero.get_image_ids(conn)
if len(ids) > 0:
conn.deleteObjects("Image", ids)
ids = ezomero.get_screen_ids(conn)
if len(ids) > 0:
conn.deleteObjects("Screen", ids, deleteChildren=True)
ids = ezomero.get_plate_ids(conn)
if len(ids) > 0:
conn.deleteObjects("Plate", ids, deleteChildren=True)


def test_ezimport(conn, monkeypatch):

# test simple import, single file
Expand All @@ -30,6 +48,7 @@ def test_ezimport(conn, monkeypatch):
monkeypatch.setattr('sys.stdin', io)
id = ezomero.ezimport(conn, fpath)
assert len(id) == 2
conn.deleteObjects("Image", id)

# # test simple import, new orphan dataset
fpath = "tests/data/test_pyramid.ome.tif"
Expand Down

0 comments on commit 51131d8

Please sign in to comment.