From ee86304f43166ae6f4ede597e2e587fa17c140fc Mon Sep 17 00:00:00 2001 From: jist <95856749+george0st@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:33:36 +0200 Subject: [PATCH 1/2] Add geo for cs_CZ --- faker/providers/geo/cs_CZ/__init__.py | 73 +++++++++++++++++++++++++++ tests/providers/test_geo.py | 5 ++ 2 files changed, 78 insertions(+) create mode 100644 faker/providers/geo/cs_CZ/__init__.py diff --git a/faker/providers/geo/cs_CZ/__init__.py b/faker/providers/geo/cs_CZ/__init__.py new file mode 100644 index 0000000000..132963175a --- /dev/null +++ b/faker/providers/geo/cs_CZ/__init__.py @@ -0,0 +1,73 @@ +from .. import Provider as GeoProvider + + +class Provider(GeoProvider): + # Source: + # https://www.latlong.net/category/cities-59-15.html + # https://github.com/33bcdd/souradnice-mest + land_coords = ( + ("50.50301", "13.63617", "Most", "CZ", "Europe/Prague"), + ("50.23271", "12.87117", "Karlovy Vary", "CZ", "Europe/Prague"), + ("50.073658", "14.418540", "Praha", "CZ", "Europe/Prague"), + ("49.144482", "15.006139", "Jindřichův Hradec", "CZ", "Europe/Prague"), + ("48.975658", "14.480255", "České Budějovice", "CZ", "Europe/Prague"), + ("50.511002", "14.150558", "Terezín", "CZ", "Europe/Prague"), + ("49.183239", "15.454273", "Telč", "CZ", "Europe/Prague"), + ("49.952431", "15.268654", "Kutná Hora", "CZ", "Europe/Prague"), + ("49.593777", "17.250879", "Olomouc", "CZ", "Europe/Prague"), + ("49.738430", "13.373637", "Plzeň", "CZ", "Europe/Prague"), + ("48.812737", "14.317466", "Český Krumlov", "CZ", "Europe/Prague"), + ("49.195061", "16.606836", "Brno", "CZ", "Europe/Prague"), + ("50.598427", "13.610242", "Litvínov", "CZ", "Europe/Prague"), + ("49.820923", "18.262524", "Ostrava", "CZ", "Europe/Prague"), + ("49.967305", "14.086384", "Beroun", "CZ", "Europe/Prague"), + ("50.678620", "14.539799", "Česká Lípa", "CZ", "Europe/Prague"), + ("50.772656", "14.212861", "DĚČÍN", "CZ", "Europe/Prague"), + ("49.682031", "18.367422", "FRÝDEK-MÍSTEK", "CZ", "Europe/Prague"), + ("49.780492", "18.430725", "HAVÍŘOV", "CZ", "Europe/Prague"), + ("49.052354", "14.434371", "Hluboká nad Vltavou", "CZ", "Europe/Prague"), + ("50.210461", "15.825311", "HRADEC KRÁLOVÉ", "CZ", "Europe/Prague"), + ("50.463598", "13.410837", "Chomutov", "CZ", "Europe/Prague"), + ("50.703569", "15.429698", "Jablonec nad Jizerou", "CZ", "Europe/Prague"), + ("50.722153", "15.170414", "Jablonec nad Nisou", "CZ", "Europe/Prague"), + ("50.435433", "15.361144", "Jičín", "CZ", "Europe/Prague"), + ("49.415860", "15.595469", "Jihlava", "CZ", "Europe/Prague"), + ("49.939604", "14.188146", "Karlštejn", "CZ", "Europe/Prague"), + ("49.856752", "18.543319", "KARVINÁ", "CZ", "Europe/Prague"), + ("50.141799", "14.106846", "Kladno", "CZ", "Europe/Prague"), + ("50.525685", "14.047429", "Lhotka nad Labem", "CZ", "Europe/Prague"), + ("49.890040", "13.581715", "Lhotka u Radnic", "CZ", "Europe/Prague"), + ("50.055957", "16.268803", "Lhoty u Potštejna", "CZ", "Europe/Prague"), + ("50.766380", "15.054439", "Liberec", "CZ", "Europe/Prague"), + ("49.772128", "15.676917", "Maleč", "CZ", "Europe/Prague"), + ("50.413525", "14.908538", "Mladá Boleslav", "CZ", "Europe/Prague"), + ("49.425534", "16.256425", "Moravecké Pavlovice", "CZ", "Europe/Prague"), + ("49.940760", "17.894899", "Opava", "CZ", "Europe/Prague"), + ("49.916939", "17.869927", "Otice", "CZ", "Europe/Prague"), + ("50.034409", "15.781299", "Pardubice", "CZ", "Europe/Prague"), + ("49.472549", "17.106851", "PROSTĚJOV", "CZ", "Europe/Prague"), + ("49.456579", "17.450330", "PŘEROV", "CZ", "Europe/Prague"), + ("50.072880", "15.802625", "Ráby", "CZ", "Europe/Prague"), + ("49.458626", "18.143131", "Rožnov pod Radhoštěm", "CZ", "Europe/Prague"), + ("49.981095", "16.877925", "Ruda nad Moravou", "CZ", "Europe/Prague"), + ("50.020519", "17.377529", "Rudná pod Pradědem", "CZ", "Europe/Prague"), + ("50.454193", "16.036726", "Slatina nad Úpou", "CZ", "Europe/Prague"), + ("49.377245", "17.670437", "Slavkov pod Hostýnem", "CZ", "Europe/Prague"), + ("49.153354", "16.876598", "Slavkov u Brna", "CZ", "Europe/Prague"), + ("49.991014", "15.350597", "Svatý Mikuláš", "CZ", "Europe/Prague"), + ("49.977941", "16.971875", "Šumperk", "CZ", "Europe/Prague"), + ("49.413089", "14.677566", "Tábor", "CZ", "Europe/Prague"), + ("50.644558", "13.835384", "Teplice", "CZ", "Europe/Prague"), + ("49.214887", "15.879652", "Třebíč", "CZ", "Europe/Prague"), + ("49.677731", "18.670890", "Třinec", "CZ", "Europe/Prague"), + ("50.151203", "16.078551", "Týniště nad Orlicí", "CZ", "Europe/Prague"), + ("50.661216", "14.053246", "ÚSTÍ NAD LABEM", "CZ", "Europe/Prague"), + ("49.139664", "18.008570", "Valašské Klobouky", "CZ", "Europe/Prague"), + ("49.471904", "17.971237", "Valašské Meziříčí", "CZ", "Europe/Prague"), + ("49.954364", "16.164268", "Vysoké Mýto", "CZ", "Europe/Prague"), + ("49.224537", "17.662863", "ZLÍN", "CZ", "Europe/Prague"), + ("50.538847", "16.213389", "Žďár nad Metují", "CZ", "Europe/Prague"), + ("50.119855", "16.069446", "Žďár nad Orlicí", "CZ", "Europe/Prague"), + ("49.564288", "15.939507", "Žďár nad Sázavou", "CZ", "Europe/Prague"), + ("49.696057", "15.813706", "Ždírec nad Doubravou", "CZ", "Europe/Prague"), + ) diff --git a/tests/providers/test_geo.py b/tests/providers/test_geo.py index c043896dc7..17d4a07525 100644 --- a/tests/providers/test_geo.py +++ b/tests/providers/test_geo.py @@ -79,6 +79,11 @@ def test_location_on_land_coords_only(self): assert Decimal(loc[0]) # Should be able to cast first two elements of tuple to Decimal assert Decimal(loc[1]) +class TestCsCz(unittest.TestCase): + def setUp(self): + self.fake = Faker("cs_CZ") + Faker.seed(0) + class TestDeAT(unittest.TestCase): """Tests in addresses in the de_AT locale""" From 2083361f1c3c9ba6670b4f7deb97f7541177dbd2 Mon Sep 17 00:00:00 2001 From: jist <95856749+george0st@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:17:59 +0200 Subject: [PATCH 2/2] Add tests --- tests/providers/test_geo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/providers/test_geo.py b/tests/providers/test_geo.py index 17d4a07525..e71b66786f 100644 --- a/tests/providers/test_geo.py +++ b/tests/providers/test_geo.py @@ -84,6 +84,17 @@ def setUp(self): self.fake = Faker("cs_CZ") 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 TestDeAT(unittest.TestCase): """Tests in addresses in the de_AT locale"""