Skip to content

Commit 262bfb2

Browse files
Hani YacoubHani Yacoub
authored andcommitted
improvements
1 parent 282798d commit 262bfb2

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

l10n_CM/Unified/test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
4242
if expected_phone:
4343
with driver.context(driver.CONTEXT_CHROME):
4444
actual_phone = autofill_popup.get_element("address-doorhanger-phone").text
45-
4645
normalize_expected = util.normalize_regional_phone_numbers(expected_phone, region)
4746
normalized_actual = util.normalize_regional_phone_numbers(actual_phone, region)
48-
4947
assert normalized_actual == normalize_expected, (
5048
f"Phone number mismatch for {region} | Expected: {normalize_expected}, Got: {normalized_actual}"
5149
)
5250

53-
print(f"DEBUG: {region} | Input: {normalized_actual} | Output: {normalize_expected}") # Debugging print
54-
5551
# Click the "Save" button
5652
autofill_popup.click_doorhanger_button("save")
5753

modules/util.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ class Utilities:
3232
Methods that may be useful, that have nothing to do with Selenium.
3333
"""
3434

35-
# COUNTRY_CODES = {
36-
# "US": "1", "CA": "1", "FR": "33", "DE": "49", "UK": "44", "JP": "81"
37-
# }
38-
3935
def __init__(self):
4036
self.state_province_abbr = {
4137
# US States
@@ -497,10 +493,9 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
497493
"DE": "49",
498494
}
499495

500-
# Remove phone number extensions (e.g., "x555" or "ext 555")
496+
# Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
501497
phone = re.sub(r"\s*(?:x|ext)\s*\d*$", "", phone, flags=re.IGNORECASE)
502-
503-
# Remove all non-numeric characters
498+
# Sub out anything that is not a digit with the empty string to ensure the phone number is formatted with no spaces or special characters
504499
digits = re.sub(r"\D", "", phone)
505500

506501
# Determine country code
@@ -511,12 +506,14 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
511506
for code in country_codes.values():
512507
if digits.startswith(code):
513508
country_code = code
514-
local_number = digits[len(code):] # Remove country code from local number
509+
# Remove country code from local number
510+
local_number = digits[len(code):]
515511
break
516512

517513
# Handle leading zero in local numbers (France & Germany)
518514
if region in ["FR", "DE"] and local_number.startswith("0"):
519-
local_number = local_number[1:] # Remove the leading zero
515+
# Remove the leading zero
516+
local_number = local_number[1:]
520517

521518
# Validate local number length
522519
if len(local_number) < 6: # Too short to be valid

0 commit comments

Comments
 (0)