Skip to content

Commit 5a58e7d

Browse files
committed
tests: add tests for primary attribute unicity
1 parent d2d56d2 commit 5a58e7d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_filling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,21 @@ def test_fix_primary_attributes_multiple_objects():
222222
assert len(user.emails) == 3
223223
primary_count = sum(1 for email in user.emails if email.primary)
224224
assert primary_count == 1
225+
226+
227+
def test_fill_with_random_values_emails_primary_constraint(testing_context):
228+
"""Ensures fill_with_random_values maintains primary=True constraint for emails."""
229+
user = User(user_name="test")
230+
filled_user = fill_with_random_values(testing_context, user, ["emails"])
231+
232+
primary_count = sum(1 for email in filled_user.emails if email.primary)
233+
assert primary_count == 1
234+
235+
236+
def test_fill_with_random_values_phone_numbers_primary_constraint(testing_context):
237+
"""Ensures fill_with_random_values maintains primary=True constraint for phone numbers."""
238+
user = User(user_name="test")
239+
filled_user = fill_with_random_values(testing_context, user, ["phoneNumbers"])
240+
241+
primary_count = sum(1 for phone in filled_user.phone_numbers if phone.primary)
242+
assert primary_count == 1

0 commit comments

Comments
 (0)