events: Add test to remove existing value for custom profile field.

Adds a test for when a value for a user's custom profile field is
removed and not set to a new value. The omission of this event in
the tests was noted as a possibility in #22103, which updated the
API documentation for these events having `null` for the field
value.

When adding the test discovered that the events logic was not
deleting the field from the user object and instead setting it to
`None`, so fixes that logic as well. There was a similar bug fixed
in commit 96c61a1a41 for when custom profile fields are removed
from a realm.
This commit is contained in:
Lauryn Menard
2023-07-31 19:39:57 +02:00
committed by Tim Abbott
parent c1cd5c527c
commit 195e5b8dc1
3 changed files with 15 additions and 5 deletions

View File

@@ -1068,7 +1068,7 @@ check_realm_user_remove = make_checker(realm_user_remove_event)
custom_profile_field_type = DictType(
required_keys=[
("id", int),
("value", str),
("value", OptionalType(str)),
],
optional_keys=[
("rendered_value", str),