Skip to content

Commit bcf8224

Browse files
committed
Update the unit tests
1 parent 7f29ce4 commit bcf8224

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/test_identity_map_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ def test_identity_map_duplicate_hashed_emails(self):
107107
self.assert_unmapped(response, "optout", hashed_opted_out_email)
108108
self.assert_unmapped(response, "optout", duplicate_hashed_opted_out_email)
109109

110-
'''def test_identity_map_empty_input(self):
110+
def test_identity_map_empty_input(self):
111111
identity_map_input = IdentityMapInput.from_emails([])
112112
response = self.identity_map_client.generate_identity_map(identity_map_input)
113-
self.assertIsNone(response.mapped_identities)
114-
self.assertIsNone(response.unmapped_identities)'''
113+
self.assertTrue(len(response.mapped_identities) == 0)
114+
self.assertTrue(len(response.unmapped_identities) == 0)
115115

116116
def test_identity_map_phones(self):
117117
identity_map_input = IdentityMapInput.from_phones(["+12345678901", "+98765432109", "+00000000000"])

uid2_client/identity_map_input.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class IdentityMapInput:
99

1010
def __init__(self, identity_type, emails_or_phones, already_hashed):
1111
self.hashed_dii_to_raw_diis = {}
12-
self.hashed_normalized_emails = []
13-
self.hashed_normalized_phones = []
12+
self.hashed_normalized_emails = None
13+
self.hashed_normalized_phones = None
1414
if identity_type == IdentityType.Email:
15+
self.hashed_normalized_emails = []
1516
for email in emails_or_phones:
1617
if already_hashed:
1718
self.hashed_normalized_emails.append(email)
@@ -20,6 +21,7 @@ def __init__(self, identity_type, emails_or_phones, already_hashed):
2021
self._add_hashed_to_raw_dii_mapping(hashed_normalized_email, email)
2122
self.hashed_normalized_emails.append(hashed_normalized_email)
2223
else: # phone
24+
self.hashed_normalized_phones = []
2325
for phone in emails_or_phones:
2426
if already_hashed:
2527
self.hashed_normalized_phones.append(phone)
@@ -58,4 +60,4 @@ def get_identity_map_input_as_json_string(self):
5860
"email_hash": self.hashed_normalized_emails,
5961
"phone_hash": self.hashed_normalized_phones
6062
}
61-
return json.dumps({k: v for k, v in json_object.items() if v is not None and len(v) > 0})
63+
return json.dumps({k: v for k, v in json_object.items() if v is not None})

0 commit comments

Comments
 (0)