Skip to content

Commit

Permalink
Update phone number formats for cs_CZ, sk_SK (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
george0st committed Apr 5, 2024
1 parent 459d045 commit f062e78
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
36 changes: 30 additions & 6 deletions faker/providers/phone_number/cs_CZ/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,34 @@

class Provider(PhoneNumberProvider):
# Phone numbers
# https://cs.wikipedia.org/wiki/Telefonn%C3%AD_%C4%8D%C3%ADslo
# https://cs.wikipedia.org/wiki/Telefonn%C3%AD_%C4%8D%C3%ADslo
# https://www.srovnejto.cz/blog/jake-jsou-telefonni-predvolby-do-zahranici/

formats = (
# 601-608
# prefix 00420
# 601-608

Check failure on line 11 in faker/providers/phone_number/cs_CZ/__init__.py

View workflow job for this annotation

GitHub Actions / flake8

continuation line unaligned for hanging indent
"00420 601 ### ###",
"00420 602 ### ###",
"00420 603 ### ###",
"00420 604 ### ###",
"00420 605 ### ###",
"00420 606 ### ###",
"00420 607 ### ###",
"00420 608 ### ###",
# 702-705
"00420 702 ### ###",
"00420 703 ### ###",
"00420 704 ### ###",
"00420 705 ### ###",
# 720-739
"00420 72# ### ###",
"00420 73# ### ###",
# 770-779
"00420 77# ### ###",
# 790-799
"00420 79# ### ###",
# prefix +420
# 601-608
"+420 601 ### ###",
"+420 602 ### ###",
"+420 603 ### ###",
Expand All @@ -15,16 +39,16 @@ class Provider(PhoneNumberProvider):
"+420 606 ### ###",
"+420 607 ### ###",
"+420 608 ### ###",
# 702-705
# 702-705
"+420 702 ### ###",
"+420 703 ### ###",
"+420 704 ### ###",
"+420 705 ### ###",
# 720-739
# 720-739
"+420 72# ### ###",
"+420 73# ### ###",
# 770-779
# 770-779
"+420 77# ### ###",
# 790-799
# 790-799
"+420 79# ### ###",
)
10 changes: 10 additions & 0 deletions faker/providers/phone_number/sk_SK/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

class Provider(PhoneNumberProvider):
formats = (
"00421 2 ########",
"00421 3# ### ####",
"00421 4# ### ####",
"00421 5# ### ####",
"00421 90# ### ###",
"00421 91# ### ###",
"00421 940 ### ###",
"00421 944 ### ###",
"00421 948 ### ###",
"00421 949 ### ###",
"+421 2 ########",
"+421 3# ### ####",
"+421 4# ### ####",
Expand Down
19 changes: 19 additions & 0 deletions tests/providers/test_phone_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ def test_phone_number(self, faker, num_samples):
phone_number = faker.phone_number()
assert pattern.fullmatch(phone_number)

class TestCsCz:

Check failure on line 65 in tests/providers/test_phone_number.py

View workflow job for this annotation

GitHub Actions / flake8

expected 2 blank lines, found 1
"""Test cs_CZ phone number provider methods"""

def test_phone_number(self, faker, num_samples):
pattern: Pattern = re.compile(r"^(00420|\+420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$")
for _ in range(num_samples):
phone_number = faker.phone_number()
assert pattern.fullmatch(phone_number)


Check warning on line 74 in tests/providers/test_phone_number.py

View workflow job for this annotation

GitHub Actions / flake8

blank line contains whitespace
class TestSkSk:
"""Test sk_SK phone number provider methods"""

def test_phone_number(self, faker, num_samples):
pattern: Pattern = re.compile(r"^(00421|\+421)? ?[2-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$")
for _ in range(num_samples):
phone_number = faker.phone_number()
assert pattern.fullmatch(phone_number)


class TestPtBr:
"""Test pt_BR phone number provider methods"""
Expand Down

0 comments on commit f062e78

Please sign in to comment.