wyby sync: skip PIN collisions with foreign manual codes
Glutz codes are globally unique; a PIN already owned by another user (e.g. manually set temporary code) is skipped with a clear WARNING instead of failing the whole run. 41 tests green.
This commit is contained in:
@@ -140,3 +140,28 @@ class TestRun:
|
||||
monkeypatch.setattr(glutz_api, "rpc", lambda m, p: {"id": "9"})
|
||||
sync.planned = [("ctx", "Codes", {"id": "1", "code": "1"})]
|
||||
assert sync.run() is True
|
||||
|
||||
|
||||
class TestPinCollision:
|
||||
def test_pin_owned_by_foreign_user_is_skipped_with_warning(self, sync):
|
||||
sync.relations = [{"parentId": "12", "childId": "55"}]
|
||||
sync.codes = [
|
||||
code_row(id=66, userId=6, code="237251", description="Bajo Temporär")
|
||||
]
|
||||
sync.plan_booking(booking(), "12", date.today())
|
||||
assert not sync.planned
|
||||
assert any("resolve manually" in s for s in sync.skipped)
|
||||
|
||||
def test_own_code_still_updates(self, sync):
|
||||
sync.relations = [{"parentId": "12", "childId": "55"}]
|
||||
sync.codes = [
|
||||
code_row(
|
||||
id=99,
|
||||
userId=55,
|
||||
code="237251",
|
||||
validFrom=f"{FUTURE}-12-27T12:45:00.000",
|
||||
validTo=f"{FUTURE}-12-27T17:15:00.000",
|
||||
)
|
||||
]
|
||||
sync.plan_booking(booking(), "12", date.today())
|
||||
assert len(sync.planned) == 1
|
||||
|
||||
Reference in New Issue
Block a user