🤖 ldap2nextcloud : synchronisation LDAP vers un carnet Nextcloud (CardDAV)

Historique regroupé en un seul commit pour ne pas publier de données
de production.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
zeguiguiandClaude Opus 5.5 committed 2026-11-17 09:47:31 +01:00
commit f6a01b85e1
42 files changed
+5538

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
from dataclasses import replace
from datetime import date
from ldap2nextcloud.model import Contact, Email, Phone, contact_href, contact_uid, fingerprint
BASE = Contact(
key="omalmare",
given_name="Oscar",
family_name="MALMARE",
full_name="MALMARE Oscar",
organization="Exemple",
title="Ingénieur",
emails=(Email("o.malmare@example.org", "work", True),),
phones=(Phone("+33123459052", "work"),),
category="Direction des systèmes d'information",
birthday=date(1968, 6, 15),
photo=b"\xff\xd8photo",
)
def test_href_is_stable_and_derived_from_key():
assert contact_href("omalmare") == contact_href("omalmare")
assert contact_href("omalmare") == f"{contact_uid('omalmare')}.vcf"
assert contact_href("omalmare") != contact_href("cbarssac")
def test_uid_is_known_uuid5():
# Valeur figée : changer le namespace casserait l'identité de toutes les fiches.
assert contact_uid("omalmare") == contact_uid("omalmare")
assert len(contact_uid("omalmare")) == 36
assert contact_uid("omalmare")[14] == "5"
def test_fingerprint_stable_for_equal_contacts():
assert fingerprint(BASE, 512, 80) == fingerprint(replace(BASE), 512, 80)
def test_fingerprint_changes_with_any_field():
reference = fingerprint(BASE, 512, 80)
for changed in (
replace(BASE, category="Autre"),
replace(BASE, photo=b"autre"),
replace(BASE, photo=None),
replace(BASE, birthday=None),
replace(BASE, phones=()),
replace(BASE, title="Chef"),
):
assert fingerprint(changed, 512, 80) != reference
def test_fingerprint_changes_with_photo_settings():
assert fingerprint(BASE, 512, 80) != fingerprint(BASE, 720, 80)
assert fingerprint(BASE, 512, 80) != fingerprint(BASE, 512, 90)