🤖 Option pour écarter les fiches sans Direction ni téléphone
Avec skip_without_group_and_phone: true dans mapping.yaml, une fiche dont l'attribut Direction est vide et qui n'a aucun téléphone n'est pas synchronisée (et est supprimée du carnet si elle y est). Un code Direction inconnu de directions.yaml ne compte pas comme vide. L'option est désactivée par défaut ; le nombre de fiches écartées est journalisé. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35f90b8fb1
commit
6d8ec287ec
8 files changed
+102
-4
No files matched your search
@@ -7,6 +7,8 @@ from PIL import Image
|
||||
|
||||
from ldap2nextcloud.carddav import CardDavError
|
||||
from ldap2nextcloud.photo import PreparedPhoto
|
||||
from dataclasses import replace
|
||||
|
||||
from ldap2nextcloud.config import Settings, load_directions, load_mapping
|
||||
from ldap2nextcloud.model import contact_href
|
||||
from ldap2nextcloud.planner import GuardError
|
||||
@@ -278,3 +280,19 @@ def test_dry_run_does_not_start_progress(tmp_path):
|
||||
progress = RecordingProgress()
|
||||
run(tmp_path, FakeClient(), dry_run=True, progress=progress)
|
||||
assert progress.total is None
|
||||
|
||||
|
||||
def test_entries_without_direction_nor_phone_are_not_synced(tmp_path, caplog):
|
||||
source = FakeSource()
|
||||
for entry in source.entries[:2]:
|
||||
del entry["telephoneNumber"]
|
||||
del source.entries[0]["usrDirectionId"] # seule la première n'a ni l'un ni l'autre
|
||||
client = FakeClient({contact_href("omalmare"): ("x", "BEGIN:VCARD")})
|
||||
settings = make_settings(tmp_path)
|
||||
strict = replace(MAPPING, skip_without_group_and_phone=True)
|
||||
with caplog.at_level(logging.INFO), StateDB(settings.state_db) as state:
|
||||
summary = run_sync(settings, strict, DIRECTIONS, source, client, state, force=True)
|
||||
assert contact_href("omalmare") not in client.cards # fiche déjà présente : supprimée
|
||||
assert contact_href("cbarssac") in client.cards
|
||||
assert (summary.created, summary.deleted) == (2, 1)
|
||||
assert "1 écartées (ni Direction ni téléphone)" in caplog.text
|
||||
Reference in new issue
Block a user