Repository: joke2k/faker
Pull request #708 (2018-02-25 09:30:45)

Added address provider for Austria (DeAT).
### What does this changes

Add address namespaces for Austria.


Patch:
diff --git a/faker/providers/address/de_AT/__init__.py b/faker/providers/address/de_AT/__init__.py
new file mode 100644
index 00000000..2fd9bbdc
--- /dev/null
+++ b/faker/providers/address/de_AT/__init__.py
@@ -0,0 +1,152 @@
+# coding=utf-8
+
+from __future__ import unicode_literals
+from .. import Provider as AddressProvider
+
+
+class Provider(AddressProvider):
+
+    city_formats = ('{{city_name}}', )
+
+    street_name_formats = (
+        '{{first_name}}-{{last_name}}-{{street_suffix_long}}',
+        '{{last_name}}{{street_suffix_short}}',
+    )
+    street_address_formats = ('{{street_name}} {{building_number}}', )
+    address_formats = ('{{street_address}}\n{{postcode}} {{city}}', )
+
+    building_number_formats = ('###', '##', '#', '#/#', )
+
+    street_suffixes_long = (
+        'Gasse', 'Platz', 'Ring', 'Straße', 'Weg'
+    )
+    street_suffixes_short = (
+        'gasse', 'platz', 'ring', 'straße', 'str.', 'weg'
+    )
+
+    # https://en.wikipedia.org/wiki/List_of_postal_codes_in_Austria
+    postcode_formats = (
+        '1###',
+        '2###',
+        '3###',
+        '4###',
+        '5###',
+        '6###',
+        '7###',
+        '8###',
+        '9###'
+    )
+
+    # https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Austria
+    cities = (
+        'Allentsteig', 'Altheim', 'Althofen', 'Amstetten', 'Ansfelden', 'Attnang-Puchheim',
+        'Bad Aussee', 'Bad Hall', 'Bad Ischl', 'Bad Leonfelden', 'Bad Radkersburg',
+        'Bad Sankt Leonhard im Lavanttal', 'Bad Vöslau', 'Baden', 'Bärnbach', 'Berndorf',
+        'Bischofshofen', 'Bleiburg', 'Bludenz', 'Braunau am Inn', 'Bregenz',
+        'Bruck an der Leitha', 'Bruck an der Mur', 'Deutsch-Wagram', 'Deutschlandsberg',
+        'Dornbirn', 'Drosendorf-Zissersdorf 1', 'Dürnstein', 'Ebenfurth', 'Ebreichsdorf',
+        'Eferding', 'Eggenburg', 'Eisenerz', 'Eisenstadt', 'Enns', 'Fehring', 'Feldbach',
+        'Feldkirch', 'Feldkirchen', 'Ferlach', 'Fischamend', 'Frauenkirchen', 'Freistadt',
+        'Friedberg', 'Friesach', 'Frohnleiten', 'Fürstenfeld', 'Gallneukirchen', 'Gänserndorf',
+        'Geras', 'Gerasdorf bei Wien', 'Gföhl', 'Gleisdorf', 'Gloggnitz', 'Gmünd',
+        'Gmünd in Kärnten', 'Gmunden', 'Graz', 'Grein', 'Grieskirchen', 'Groß-Enzersdorf',
+        'Groß-Gerungs', 'Groß-Siegharts', 'Güssing', 'Haag', 'Hainburg an der Donau', 'Hainfeld',
+        'Hall in Tirol', 'Hallein', 'Hardegg', 'Hartberg', 'Heidenreichstein', 'Herzogenburg',
+        'Imst', 'Innsbruck', 'Jennersdorf', 'Judenburg', 'Kapfenberg', 'Kindberg', 'Klagenfurt',
+        'Klosterneuburg', 'Knittelfeld', 'Köflach', 'Korneuburg', 'Krems an der Donau', 'Kufstein',
+        'Laa an der Thaya', 'Laakirchen', 'Landeck', 'Langenlois', 'Leibnitz', 'Leoben', 'Lienz',
+        'Liezen', 'Lilienfeld', 'Linz', 'Litschau', 'Maissau', 'Mank', 'Mannersdorf am Leithagebirge',
+        'Marchegg', 'Marchtrenk', 'Mariazell', 'Mattersburg', 'Mattighofen', 'Mautern an der Donau',
+        'Melk', 'Mistelbach an der Zaya', 'Mödling', 'Murau', 'Mureck', 'Mürzzuschlag', 'Neulengbach',
+        'Neumarkt am Wallersee', 'Neunkirchen', 'Neusiedl am See', 'Oberndorf bei Salzburg',
+        'Oberpullendorf', 'Oberwart', 'Oberwälz', 'Perg', 'Peuerbach', 'Pinkafeld', 'Pöchlarn',
+        'Poysdorf', 'Pregarten', 'Pulkau', 'Purbach am Neusiedler See', 'Purkersdorf',
+        'Raabs an der Thaya', 'Radenthein', 'Radstadt', 'Rattenberg', 'Retz', 'Ried im Innkreis',
+        'Rohrbach in Oberösterreich', 'Rottenmann', 'Rust', 'Saalfelden am Steinernen Meer',
+        'Salzburg', 'Sankt Andrä im Lavanttal', 'Sankt Johann im Pongau', 'Sankt Pölten',
+        'Sankt Valentin', 'Sankt Veit an der Glan', 'Schärding', 'Scheibbs', 'Schladming',
+        'Schrattenthal', 'Schrems', 'Schwanenstadt', 'Schwaz', 'Schwechat', 'Spittal an der Drau',
+        'Stadtschlaining', 'Steyr', 'Steyregg', 'Stockerau', 'Straßburg', 'Ternitz', 'Traiskirchen',
+        'Traismauer', 'Traun', 'Trieben', 'Trofaiach', 'Tulln an der Donau', 'Villach', 'Vils',
+        'Vöcklabruck', 'Voitsberg', 'Völkermarkt', 'Waidhofen an der Thaya', 'Waidhofen an der Ybbs',
+        'Weitra', 'Weiz', 'Wels', 'Wien', 'Wiener Neustadt', 'Wieselburg', 'Wilhelmsburg', 'Wolfsberg',
+        'Wolkersdorf', 'Wörgl', 'Ybbs an der Donau', 'Zell am See', 'Zeltweg', 'Zistersdorf', 'Zwettl'
+    )
+
+    # https://en.wikipedia.org/wiki/States_of_Austria
+    states = (
+        'Wien', 'Steiermark', 'Burgenland', 'Tirol', 'Niederösterreich',
+        'Oberösterreich', 'Salzburg', 'Kärnten', 'Vorarlberg'
+    )
+
+    countries = (
+        'Afghanistan', 'Alandinseln', 'Albanien', 'Algerien',
+        'Amerikanisch-Ozeanien', 'Amerikanisch-Samoa',
+        'Amerikanische Jungferninseln', 'Andorra', 'Angola', 'Anguilla',
+        'Antarktis', 'Antigua und Barbuda', 'Argentinien', 'Armenien', 'Aruba',
+        'Aserbaidschan', 'Australien', 'Bahamas', 'Bahrain', 'Bangladesch',
+        'Barbados', 'Belarus', 'Belgien', 'Belize', 'Benin', 'Bermuda',
+        'Bhutan', 'Bolivien', 'Bosnien und Herzegowina', 'Botsuana',
+        'Bouvetinsel', 'Brasilien', 'Britische Jungferninseln',
+        'Britisches Territorium im Indischen Ozean', 'Brunei Darussalam',
+        'Bulgarien', 'Burkina Faso', 'Burundi', 'Chile', 'China', 'Cookinseln',
+        'Costa Rica', 'Côte d’Ivoire', 'Demokratische Republik Kongo',
+        'Demokratische Volksrepublik Korea', 'Deutschland', 'Dominica',
+        'Dominikanische Republik', 'Dschibuti', 'Dänemark', 'Ecuador',
+        'El Salvador', 'Eritrea', 'Estland', 'Falklandinseln', 'Fidschi',
+        'Finnland', 'Frankreich', 'Französisch-Guayana',
+        'Französisch-Polynesien', 'Färöer', 'Gabun', 'Gambia', 'Georgien',
+        'Ghana', 'Gibraltar', 'Grenada', 'Griechenland', 'Grönland',
+        'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea',
+        'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard- und McDonald-Inseln',
+        'Honduras', 'Indien', 'Indonesien', 'Irak', 'Iran', 'Irland', 'Island',
+        'Isle of Man', 'Israel', 'Italien', 'Jamaika', 'Japan', 'Jemen',
+        'Jersey', 'Jordanien', 'Kaimaninseln', 'Kambodscha', 'Kamerun',
+        'Kanada', 'Kap Verde', 'Kasachstan', 'Katar', 'Kenia', 'Kirgisistan',
+        'Kiribati', 'Kokosinseln', 'Kolumbien', 'Komoren', 'Kongo', 'Kroatien',
+        'Kuba', 'Kuwait', 'Laos', 'Lesotho', 'Lettland', 'Libanon', 'Liberia',
+        'Libyen', 'Liechtenstein', 'Litauen', 'Luxemburg', 'Madagaskar',
+        'Malawi', 'Malaysia', 'Malediven', 'Mali', 'Malta', 'Marokko',
+        'Marshallinseln', 'Martinique', 'Mauretanien', 'Mauritius', 'Mayotte',
+        'Mazedonien', 'Mexiko', 'Mikronesien', 'Monaco', 'Mongolei',
+        'Montenegro', 'Montserrat', 'Mosambik', 'Myanmar', 'Namibia', 'Nauru',
+        'Nepal', 'Neukaledonien', 'Neuseeland', 'Nicaragua', 'Niederlande',
+        'Niederländische Antillen', 'Niger', 'Nigeria', 'Niue', 'Norfolkinsel',
+        'Norwegen', 'Nördliche Marianen', 'Oman', 'Osttimor', 'Pakistan',
+        'Palau', 'Palästinensische Gebiete', 'Panama', 'Papua-Neuguinea',
+        'Paraguay', 'Peru', 'Philippinen', 'Pitcairn', 'Polen', 'Portugal',
+        'Puerto Rico', 'Republik Korea', 'Republik Moldau', 'Ruanda',
+        'Rumänien', 'Russische Föderation', 'Réunion', 'Salomonen', 'Sambia',
+        'Samoa', 'San Marino', 'Saudi-Arabien', 'Schweden', 'Schweiz',
+        'Senegal', 'Serbien', 'Serbien und Montenegro', 'Seychellen',
+        'Sierra Leone', 'Simbabwe', 'Singapur', 'Slowakei', 'Slowenien',
+        'Somalia', 'Sonderverwaltungszone Hongkong',
+        'Sonderverwaltungszone Macao', 'Spanien', 'Sri Lanka',
+        'St. Barthélemy', 'St. Helena', 'St. Kitts und Nevis', 'St. Lucia',
+        'St. Martin', 'St. Pierre und Miquelon',
+        'St. Vincent und die Grenadinen', 'Sudan', 'Suriname',
+        'Svalbard und Jan Mayen', 'Swasiland', 'Syrien',
+        'São Tomé und Príncipe', 'Südafrika',
+        'Südgeorgien und die Südlichen Sandwichinseln', 'Tadschikistan',
+        'Taiwan', 'Tansania', 'Thailand', 'Togo', 'Tokelau', 'Tonga',
+        'Trinidad und Tobago', 'Tschad', 'Tschechische Republik', 'Tunesien',
+        'Turkmenistan', 'Turks- und Caicosinseln', 'Tuvalu', 'Türkei',
+        'Uganda', 'Ukraine', 'Ungarn', 'Uruguay', 'Usbekistan', 'Vanuatu',
+        'Vatikanstadt', 'Venezuela', 'Vereinigte Arabische Emirate',
+        'Vereinigte Staaten', 'Vereinigtes Königreich', 'Vietnam',
+        'Wallis und Futuna', 'Weihnachtsinsel', 'Westsahara',
+        'Zentralafrikanische Republik', 'Zypern', 'Ägypten',
+        'Äquatorialguinea', 'Äthiopien', 'Äußeres Ozeanien', 'Österreich',
+    )
+
+    def street_suffix_short(self):
+        return self.random_element(self.street_suffixes_short)
+
+    def street_suffix_long(self):
+        return self.random_element(self.street_suffixes_long)
+
+    def city_name(self):
+        return self.random_element(self.cities)
+
+    def state(self):
+        return self.random_element(self.states)
\ No newline at end of file


Test patch:
diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py
index b22444b8..513a6443 100644
--- a/tests/providers/test_address.py
+++ b/tests/providers/test_address.py
@@ -9,6 +9,7 @@ from decimal import Decimal
 from ukpostcodeparser.parser import parse_uk_postcode
 
 from faker import Faker
+from faker.providers.address.de_AT import Provider as DeAtProvider
 from faker.providers.address.de_DE import Provider as DeProvider
 from faker.providers.address.el_GR import Provider as GrProvider
 from faker.providers.address.en_AU import Provider as EnAuProvider
@@ -21,6 +22,42 @@ from faker.providers.address.ne_NP import Provider as NeProvider
 from six import string_types
 
 
+class TestDeAT(unittest.TestCase):
+    """ Tests in addresses in the de_AT locale """
+
+    def setUp(self):
+        self.factory = Faker('de_AT')
+
+    def test_city(self):
+        city = self.factory.city()
+        assert isinstance(city, string_types)
+        assert city in DeAtProvider.cities
+
+    def test_state(self):
+        state = self.factory.state()
+        assert isinstance(state, string_types)
+        assert state in DeAtProvider.states
+
+    def test_street_suffix_short(self):
+        street_suffix_short = self.factory.street_suffix_short()
+        assert isinstance(street_suffix_short, string_types)
+        assert street_suffix_short in DeAtProvider.street_suffixes_short
+
+    def test_street_suffix_long(self):
+        street_suffix_long = self.factory.street_suffix_long()
+        assert isinstance(street_suffix_long, string_types)
+        assert street_suffix_long in DeAtProvider.street_suffixes_long
+
+    def test_country(self):
+        country = self.factory.country()
+        assert isinstance(country, string_types)
+        assert country in DeAtProvider.countries
+
+    def test_postcode(self):
+        postcode = self.factory.postcode()
+        assert re.match("\d{4}", postcode)
+
+
 class TestDeDE(unittest.TestCase):
     """ Tests in addresses in the de_DE locale """