Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

quality: Add store tests

Clémence Lesné4543e4ba10c6
diff --git a/tests/store.py b/tests/store.py
new file mode 100644
index 0000000..8bf3373
--- /dev/null
+++ b/tests/store.py
@@ -0,0 +1,41 @@
+from helpers.config import CONFIG
+from helpers.config_models.database import ModeEnum as DatabaseModeEnum
+from models.call import CallModel
+import pytest
+
+
+_db = CONFIG.database.instance()
+
+
+ "database_mode",
+ [
+ pytest.param(
+ DatabaseModeEnum.SQLITE,
+ id="sqlite",
+ ),
+ pytest.param(
+ DatabaseModeEnum.COSMOS_DB,
+ id="cosmos_db",
+ ),
+ ],
+)
+async def test_acid(call_mock: CallModel, database_mode: DatabaseModeEnum) -> None:
+ # Set database mode
+ CONFIG.database.mode = database_mode
+
+ # Check not exists
+ assert not await _db.call_aget(call_mock.call_id)
+ assert not await _db.call_asearch_one(call_mock.phone_number)
+ assert call_mock not in (await _db.call_asearch_all(call_mock.phone_number) or [])
+
+ # Insert test call
+ await _db.call_aset(call_mock)
+
+ # Check point read
+ assert await _db.call_aget(call_mock.call_id) == call_mock
+ # Check search one
+ assert await _db.call_asearch_one(call_mock.phone_number) == call_mock
+ # Check search all
+ assert call_mock in (await _db.call_asearch_all(call_mock.phone_number) or [])