From 92660a0f43f1d1b0e52c8deff71e5ed45cc9ac48 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Wed, 17 Jul 2024 22:39:30 +0700 Subject: [PATCH] fix: update now failing test Signed-off-by: F.N. Claessen --- .../tests/test_belief_persistence.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/timely_beliefs/tests/test_belief_persistence.py b/timely_beliefs/tests/test_belief_persistence.py index da4eb8d2..20282f9a 100644 --- a/timely_beliefs/tests/test_belief_persistence.py +++ b/timely_beliefs/tests/test_belief_persistence.py @@ -61,9 +61,10 @@ def test_fail_adding_to_session( session=session, sensor=time_slot_sensor, ) + n_beliefs_before = len(bdf) - # Attempting to save the same data should fail, even if we expunge everything from the session - with pytest.raises(IntegrityError): + if bulk_save_objects: + # Attempting to save the same data should not yield new data in the database DBTimedBelief.add_to_session( session, bdf, @@ -71,3 +72,19 @@ def test_fail_adding_to_session( bulk_save_objects=bulk_save_objects, commit_transaction=True, ) + bdf = DBTimedBelief.search_session( + session=session, + sensor=time_slot_sensor, + ) + n_beliefs_after = len(bdf) + assert n_beliefs_after == n_beliefs_before + else: + # Attempting to save the same data should fail, even if we expunge everything from the session + with pytest.raises(IntegrityError): + DBTimedBelief.add_to_session( + session, + bdf, + expunge_session=True, + bulk_save_objects=bulk_save_objects, + commit_transaction=True, + )