From a0799051e2dc126b16966a50b6a5ea634d283a23 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 2 May 2024 10:16:16 -0500 Subject: [PATCH 1/2] Fixing DAGSet ID test --- test/test_basic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_basic.py b/test/test_basic.py index 4b672b2..fb69d44 100644 --- a/test/test_basic.py +++ b/test/test_basic.py @@ -181,18 +181,18 @@ def test_id_safety(request): with pytest.raises(ValueError, match="already"): v1.id = used_vol_id - safe_vol_id = 9876 + safe_vol_id = 101 v1.id = safe_vol_id assert v1.id == safe_vol_id - v2 = Volume.create(model) + v2 = dagmc.Volume.create(model) assert v2.id == safe_vol_id + 1 - safe_vol_id = 101 + safe_vol_id = 9876 v1.id = safe_vol_id del v2 - v3 = Volume.create(model) + v3 = dagmc.Volume.create(model) assert v3.id == safe_vol_id + 1 s1 = model.surfaces_by_id[1] From b6c123fe3120fab43f36a4c46bd823a4d71dfc25 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 2 May 2024 14:41:53 -0500 Subject: [PATCH 2/2] Correct del call and add comments on intended testing --- test/test_basic.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test_basic.py b/test/test_basic.py index fb69d44..8ccf01d 100644 --- a/test/test_basic.py +++ b/test/test_basic.py @@ -181,17 +181,24 @@ def test_id_safety(request): with pytest.raises(ValueError, match="already"): v1.id = used_vol_id - safe_vol_id = 101 + # set volume 1 to a safe ID and ensure assignment was successful this + # assignment should free the original ID of 1 for use + safe_vol_id = 9876 v1.id = safe_vol_id assert v1.id == safe_vol_id + # create a second volume and ensure it gets the next available ID v2 = dagmc.Volume.create(model) assert v2.id == safe_vol_id + 1 - safe_vol_id = 9876 + # update the value of the first volume, freeing the ID + safe_vol_id = 101 v1.id = safe_vol_id - del v2 + # delete the second volume, freeing its ID as well + v2.delete() + # create a new volume and ensure that it is automatically assigned the + # lowest available ID v3 = dagmc.Volume.create(model) assert v3.id == safe_vol_id + 1