- Implemented the Drift module with a new FastAPI router and HTML templates for the frontend. - Created database tables for drift sources, devices, events, event history, and customer mappings. - Added functionality to manage and display drift events, including filtering and bulk mapping of monitors to customers. - Introduced tests for the Drift module, covering various functionalities including event blacklisting and UISP connector configuration. - Enhanced Telefoni service tests to ensure proper call termination handling.
31 lines
1020 B
Python
31 lines
1020 B
Python
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from app.modules.telefoni.backend.service import TelefoniService
|
|
|
|
|
|
def test_terminate_call_creates_placeholder_row_when_missing(monkeypatch):
|
|
calls = []
|
|
|
|
def fake_execute_query(query, params=(), *args, **kwargs):
|
|
calls.append((query, params))
|
|
return [{"id": 1}]
|
|
|
|
def fake_upsert_call(*, callid, user_id, direction, ekstern_nummer, intern_extension, kontakt_id, raw_payload, started_at):
|
|
return {
|
|
"id": 42,
|
|
"callid": callid,
|
|
"direction": direction,
|
|
"started_at": started_at,
|
|
}
|
|
|
|
monkeypatch.setattr("app.modules.telefoni.backend.service.execute_query", fake_execute_query)
|
|
monkeypatch.setattr(TelefoniService, "upsert_call", staticmethod(fake_upsert_call))
|
|
|
|
result = TelefoniService.terminate_call("call-123", 120)
|
|
|
|
assert result is True
|
|
assert any("INSERT INTO telefoni_opkald" in query for query, _ in calls)
|