From a34cf4845e765a35c7ae0092b9d50d8c9f369b5b Mon Sep 17 00:00:00 2001 From: Benyamin Date: Sat, 18 Nov 2023 12:27:15 +0330 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20=F0=9F=A4=A1=20init=20unittest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_crud.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_crud.py diff --git a/tests/test_crud.py b/tests/test_crud.py new file mode 100644 index 0000000..264396a --- /dev/null +++ b/tests/test_crud.py @@ -0,0 +1,30 @@ +from datetime import datetime + +from ifsguid import crud, models, utils, schemas + + +### Unit Tests ### + + +def test_get_interactions(db): + timestamp = utils.convert_timezone(datetime.now()) + interaction1 = models.Interaction( + settings=dict(model_name="model1", role="role1", prompt="prompt1"), + created_at=timestamp, + updated_at=timestamp, + ) + interaction2 = models.Interaction( + settings=dict(model_name="model2", role="role2", prompt="prompt2"), + created_at=timestamp, + updated_at=timestamp, + ) + db.add(interaction1) + db.add(interaction2) + db.commit() + + interactions = crud.get_interactions(db) + assert len(interactions) == 2 + assert interactions[0].settings["model_name"] == "model1" + assert interactions[1].settings["model_name"] == "model2" + +