Fix contact filtering and compact workspace alerts
This commit is contained in:
@@ -6,6 +6,7 @@ from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from sqlalchemy import create_engine, inspect
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from govoplan_core.core.change_sequence import ChangeSequenceEntry
|
||||
@@ -142,6 +143,7 @@ from govoplan_addresses.backend.service import (
|
||||
suggest_duplicate_contacts,
|
||||
resolve_trusted_deployment_carddav_credential_ref,
|
||||
_carddav_client_for_source,
|
||||
_filtered_contact_query,
|
||||
)
|
||||
|
||||
|
||||
@@ -309,6 +311,27 @@ class AddressServiceTest(unittest.TestCase):
|
||||
self.session.commit()
|
||||
self.assertEqual([item.id for item in list_contacts(self.session, self.principal, address_book_id=book.id)], [contact.id])
|
||||
|
||||
def test_contact_query_is_postgresql_json_safe(self) -> None:
|
||||
book = create_address_book(
|
||||
self.session,
|
||||
self.principal,
|
||||
AddressBookCreateRequest(scope_type="user", name="PostgreSQL-safe"),
|
||||
)
|
||||
self.session.commit()
|
||||
|
||||
contact_query = _filtered_contact_query(
|
||||
self.session,
|
||||
self.principal,
|
||||
address_book_id=book.id,
|
||||
address_list_id=None,
|
||||
query="example",
|
||||
include_deleted=False,
|
||||
)
|
||||
compiled = str(contact_query.statement.compile(dialect=postgresql.dialect()))
|
||||
|
||||
self.assertNotIn("SELECT DISTINCT", compiled.upper())
|
||||
self.assertIn("EXISTS", compiled.upper())
|
||||
|
||||
def test_contact_and_relationship_routes_emit_value_free_audit_evidence(self) -> None:
|
||||
book = create_address_book(
|
||||
self.session,
|
||||
|
||||
Reference in New Issue
Block a user