Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geo for pl_PL #2044

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions faker/providers/geo/pl_PL/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from .. import Provider as GeoProvider


class Provider(GeoProvider):
# Source:
# https://latitude.to/map/pl/poland/cities/
land_coords = (
("52.22977", "21.01178", "Warsaw", "PL", "Europe/Warsaw"),
("51.75", "19.46667", "Łódź", "PL", "Europe/Warsaw"),
("50.06143", "19.93658", "Krakow", "PL", "Europe/Warsaw"),
("51.1", "17.03333", "Wrocław", "PL", "Europe/Warsaw"),
("52.40692", "16.92993", "Poznań", "PL", "Europe/Warsaw"),
("54.35205", "18.64637", "Gdańsk", "PL", "Europe/Warsaw"),
("53.42894", "14.55302", "Szczecin", "PL", "Europe/Warsaw"),
("53.1235", "18.00762", "Bydgoszcz", "PL", "Europe/Warsaw"),
("51.25", "22.56667", "Lublin", "PL", "Europe/Warsaw"),
("50.25841", "19.02754", "Katowice", "PL", "Europe/Warsaw"),
("53.13333", "23.16433", "Białystok", "PL", "Europe/Warsaw"),
("54.51889", "18.53188", "Gdynia", "PL", "Europe/Warsaw"),
("50.79646", "19.12409", "Częstochowa", "PL", "Europe/Warsaw"),
("50.28682", "19.10385", "Sosnowiec", "PL", "Europe/Warsaw"),
("51.40253", "21.14714", "Radom", "PL", "Europe/Warsaw"),
("52.1934", "21.03487", "Mokotów", "PL", "Europe/Warsaw"),
("53.01375", "18.59814", "Toruń", "PL", "Europe/Warsaw"),
("50.87033", "20.62752", "Kielce", "PL", "Europe/Warsaw"),
("50.29761", "18.67658", "Gliwice", "PL", "Europe/Warsaw"),
("50.32492", "18.78576", "Zabrze", "PL", "Europe/Warsaw"),
("50.34802", "18.93282", "Bytom", "PL", "Europe/Warsaw"),
)
16 changes: 16 additions & 0 deletions tests/providers/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ def test_local_longitude(self):
local_longitude = self.fake.local_longitude()
assert re.match(r"1[1-5]\.\d+", str(local_longitude))

class TestPlPl(unittest.TestCase):
def setUp(self):
self.fake = Faker("pl_PL")
Faker.seed(0)

def test_location_on_land(self):
loc = self.fake.location_on_land()
assert isinstance(loc, tuple)
assert len(loc) == 5
assert Decimal(loc[0]) # Should be able to cast first two elements of tuple to Decimal
assert Decimal(loc[1])
assert isinstance(loc[2], str) # Place is a string
assert isinstance(loc[3], str) # Country code is a string
assert len(loc[3]) == 2 # Country code is two letters
assert isinstance(loc[4], str) # Timezone is a string


class TestPtPT(unittest.TestCase):
def setUp(self):
Expand Down