Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Garcia Reolid <[email protected]>
  • Loading branch information
victorgarcia98 committed Jul 17, 2024
1 parent 9b43136 commit 4f2808b
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions timely_beliefs/tests/test_belief_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,31 @@ def test_adding_to_session(
assert len(bdf) == len(new_bdf)


@pytest.mark.parametrize("bulk_save_objects", [False, True])
def test_fail_adding_to_session(
bulk_save_objects: bool,
def test_adding_to_session_succeeds(
time_slot_sensor: DBSensor,
rolling_day_ahead_beliefs_about_time_slot_events,
):

# Retrieve some data from the database
bdf = DBTimedBelief.search_session(
session=session,
sensor=time_slot_sensor,
)

# Attempting to save the same data should not fail, even if we expunge everything from the session
try:
DBTimedBelief.add_to_session(
session,
bdf,
expunge_session=True,
bulk_save_objects=True,
commit_transaction=True,
)
except IntegrityError as exception:
raise pytest.fail("DID RAISE {0}".format(exception))


def test_adding_to_session_fails(
time_slot_sensor: DBSensor,
rolling_day_ahead_beliefs_about_time_slot_events,
):
Expand All @@ -69,7 +91,7 @@ def test_fail_adding_to_session(
session,
bdf,
expunge_session=True,
bulk_save_objects=bulk_save_objects,
bulk_save_objects=False,
commit_transaction=True,
)
bdf = DBTimedBelief.search_session(
Expand Down

0 comments on commit 4f2808b

Please sign in to comment.