Repository: joke2k/faker
Pull request #1147 (2020-04-04 18:26:53)

Added color provider for es_ES locale.




Patch:
diff --git a/faker/providers/address/en_GB/__init__.py b/faker/providers/address/en_GB/__init__.py
index 9bc758ba..282ac458 100644
--- a/faker/providers/address/en_GB/__init__.py
+++ b/faker/providers/address/en_GB/__init__.py
@@ -26,6 +26,102 @@ class Provider(AddressProvider):
         'side',
         'shire',
     )
+    counties = (
+        'Bedfordshire',
+        'Buckinghamshire',
+        'Cambridgeshire',
+        'Cheshire',
+        'Cleveland',
+        'Cornwall',
+        'Cumbria',
+        'Derbyshire',
+        'Devon',
+        'Dorset',
+        'Durham',
+        'East Sussex',
+        'Essex',
+        'Gloucestershire',
+        'Greater London',
+        'Greater Manchester',
+        'Hampshire',
+        'Hertfordshire',
+        'Kent',
+        'Lancashire',
+        'Leicestershire',
+        'Lincolnshire',
+        'Merseyside',
+        'Norfolk',
+        'North Yorkshire',
+        'Northamptonshire',
+        'Northumberland',
+        'Nottinghamshire',
+        'Oxfordshire',
+        'Shropshire',
+        'Somerset',
+        'South Yorkshire',
+        'Staffordshire',
+        'Suffolk',
+        'Surrey',
+        'Tyne and Wear',
+        'Warwickshire',
+        'West Berkshire',
+        'West Midlands',
+        'West Sussex',
+        'West Yorkshire',
+        'Wiltshire',
+        'Worcestershire',
+        'Flintshire',
+        'Glamorgan',
+        'Merionethshire',
+        'Monmouthshire',
+        'Montgomeryshire',
+        'Pembrokeshire',
+        'Radnorshire',
+        'Anglesey',
+        'Breconshire',
+        'Caernarvonshire',
+        'Cardiganshire',
+        'Carmarthenshire',
+        'Denbighshire',
+        'Aberdeen City',
+        'Aberdeenshire',
+        'Angus',
+        'Argyll and Bute',
+        'City of Edinburgh',
+        'Clackmannanshire',
+        'Dumfries and Galloway',
+        'Dundee City',
+        'East Ayrshire',
+        'East Dunbartonshire',
+        'East Lothian',
+        'East Renfrewshire',
+        'Eilean Siar',
+        'Falkirk',
+        'Fife',
+        'Glasgow City',
+        'Highland',
+        'Inverclyde',
+        'Midlothian',
+        'Moray',
+        'North Ayrshire',
+        'North Lanarkshire',
+        'Orkney Islands',
+        'Perth and Kinross',
+        'Renfrewshire',
+        'Scottish Borders',
+        'Shetland Islands',
+        'South Ayrshire',
+        'South Lanarkshire',
+        'Stirling',
+        'West Dunbartonshire',
+        'West Lothian',
+        'Antrim',
+        'Armagh',
+        'Down',
+        'Fermanagh',
+        'Derry and Londonderry',
+        'Tyrone',
+    )
     building_number_formats = ('#', '##', '###')
     street_suffixes = (
         'alley',
@@ -329,3 +425,6 @@ class Provider(AddressProvider):
 
     def secondary_address(self):
         return self.bothify(self.random_element(self.secondary_address_formats))
+
+    def county(self):
+        return self.random_element(self.counties)
diff --git a/faker/providers/bank/es_ES/__init__.py b/faker/providers/bank/es_ES/__init__.py
new file mode 100644
index 00000000..807d57e4
--- /dev/null
+++ b/faker/providers/bank/es_ES/__init__.py
@@ -0,0 +1,6 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    bban_format = '####################'
+    country_code = 'ES'
diff --git a/faker/providers/color/es_ES/__init__.py b/faker/providers/color/es_ES/__init__.py
new file mode 100644
index 00000000..24cf88e1
--- /dev/null
+++ b/faker/providers/color/es_ES/__init__.py
@@ -0,0 +1,155 @@
+from collections import OrderedDict
+
+from .. import Provider as ColorProvider
+
+localized = True
+
+
+class Provider(ColorProvider):
+    all_colors = OrderedDict((
+        ("Agua marina medio", "#66CDAA"),
+        ("Agua-marina", "#7FFFD4"),
+        ("Almendra blanqueado", "#FFEBCD"),
+        ("Amarillo", "#FFFF00"),
+        ("Amarillo claro", "#FFFFE0"),
+        ("Amarillo dorado", "#DAA520"),
+        ("Amarillo dorado claro", "#FAFAD2"),
+        ("Amarillo dorado oscuro", "#B8860B"),
+        ("Amarillo dorado pálido", "#EEE8AA"),
+        ("Amarillo trigo", "#F5DEB3"),
+        ("Amarillo verde", "#9ACD32"),
+        ("Azul", "#0000FF"),
+        ("Azul Alicia", "#F0F8FF"),
+        ("Azul acero", "#4682B4"),
+        ("Azul acero claro", "#B0C4DE"),
+        ("Azul anciano", "#6495ED"),
+        ("Azul azur", "#F0FFFF"),
+        ("Azul cadete", "#5F9EA0"),
+        ("Azul cielo", "#87CEEB"),
+        ("Azul cielo claro", "#87CEFA"),
+        ("Azul cielo profundo", "#00BFFF"),
+        ("Azul claro", "#ADD8E6"),
+        ("Azul lona", "#1E90FF"),
+        ("Azul marino", "#000080"),
+        ("Azul medianoche", "#191970"),
+        ("Azul medio", "#0000CD"),
+        ("Azul oscuro", "#00008B"),
+        ("Azul pizarra", "#6A5ACD"),
+        ("Azul pizarra medio", "#7B68EE"),
+        ("Azul pizarra oscuro", "#483D8B"),
+        ("Azul polvo", "#B0E0E6"),
+        ("Azul real", "#4169E1"),
+        ("Azul violeta", "#8A2BE2"),
+        ("Beige", "#F5F5DC"),
+        ("Beige antiguo", "#FAEBD7"),
+        ("Beige limón", "#FFFACD"),
+        ("Beige melocotón", "#FFDAB9"),
+        ("Beige mocasín", "#FFE4B5"),
+        ("Beige papaya", "#FFEFD5"),
+        ("Bisque", "#FFE4C4"),
+        ("Blanco", "#FFFFFF"),
+        ("Blanco concha", "#FFF5EE"),
+        ("Blanco encaje", "#FDF5E6"),
+        ("Blanco fantasma", "#F8F8FF"),
+        ("Blanco floral", "#FFFAF0"),
+        ("Blanco humo", "#F5F5F5"),
+        ("Blanco lavanda", "#FFF0F5"),
+        ("Blanco lino", "#FAF0E6"),
+        ("Blanco menta", "#F5FFFA"),
+        ("Blanco navajo", "#FFDEAD"),
+        ("Blanco nieve", "#FFFAFA"),
+        ("Caqui", "#6B8E23"),
+        ("Caqui oscuro", "#BDB76B"),
+        ("Chartreuse", "#7FFF00"),
+        ("Chocolate", "#D2691E"),
+        ("Cian", "#00FFFF"),
+        ("Cian clarto", "#E0FFFF"),
+        ("Ciruela", "#DDA0DD"),
+        ("Coral", "#FF7F50"),
+        ("Coral claro", "#F08080"),
+        ("Amarillo maíz dulce", "#FFF8DC"),
+        ("Cyan oscuro", "#008B8B"),
+        ("Fucsia", "#FF00FF"),
+        ("Granate", "#800000"),
+        ("Gris", "#808080"),
+        ("Gris claro", "#D3D3D3"),
+        ("Gris gainsboro (Estaño)", "#DCDCDC"),
+        ("Gris mate", "#696969"),
+        ("Gris oscuro", "#A9A9A9"),
+        ("Gris pizarra", "#708090"),
+        ("Gris pizarra claro", "#778899"),
+        ("Gris pizarra oscuro", "#2F4F4F"),
+        ("Lavanda", "#E6E6FA"),
+        ("Lima", "#00FF00"),
+        ("Magenta", "#FF00FF"),
+        ("Magenta oscuro", "#8B008B"),
+        ("Marfil", "#FFFFF0"),
+        ("Marrón", "#A52A2A"),
+        ("Marrón arena", "#F4A460"),
+        ("Marrón caqui", "#F0E68C"),
+        ("Marrón cuero", "#8B4513"),
+        ("Marrón madera rústica", "#DEB887"),
+        ("Marrón perú", "#CD853F"),
+        ("Marrón rojizo", "#D2B48C"),
+        ("Marrón rosado", "#BC8F8F"),
+        ("Marrón siena", "#A0522D"),
+        ("Melón dulce", "#F0FFF0"),
+        ("Naranja", "#FFA500"),
+        ("Naranja oscuro", "#FF8C00"),
+        ("Negro", "#000000"),
+        ("Oliva", "#808000"),
+        ("Oro", "#FFD700"),
+        ("Orquídea", "#DA70D6"),
+        ("Orquídea medio", "#BA55D3"),
+        ("Orquídea púrpura oscuro", "#9932CC"),
+        ("Plata", "#C0C0C0"),
+        ("Púrpura", "#800080"),
+        ("Púrpura medio", "#9370DB"),
+        ("Rojo", "#FF0000"),
+        ("Rojo anaranjado", "#FF4500"),
+        ("Rojo carmesí", "#DC143C"),
+        ("Rojo indio", "#CD5C5C"),
+        ("Rojo ladrillo", "#B22222"),
+        ("Rojo oscuro", "#8B0000"),
+        ("Rojo tomate", "#FF6347"),
+        ("Rojo violeta medio", "#C71585"),
+        ("Rosa", "#FFC0CB"),
+        ("Rosa brumoso", "#FFE4E1"),
+        ("Rosa caliente", "#FF69B4"),
+        ("Rosa claro", "#FFB6C1"),
+        ("Rosa profundo", "#FF1493"),
+        ("Salmón", "#FA8072"),
+        ("Salmón claro", "#FFA07A"),
+        ("Salmón oscuro", "#E9967A"),
+        ("Turquesa", "#40E0D0"),
+        ("Turquesa medio", "#48D1CC"),
+        ("Turquesa oscuro", "#00CED1"),
+        ("Turquesa pálido", "#AFEEEE"),
+        ("Verde", "#008000"),
+        ("Verde azulado", "#008080"),
+        ("Verde bosque", "#228B22"),
+        ("Verde claro", "#90EE90"),
+        ("Verde lima", "#32CD32"),
+        ("Verde limón", "#ADFF2F"),
+        ("Verde mar", "#2E8B57"),
+        ("Verde mar claro", "#20B2AA"),
+        ("Verde mar medio", "#3CB371"),
+        ("Verde mar oscuro", "#8FBC8F"),
+        ("Verde oliva oscuro", "#556B2F"),
+        ("Verde oscuro", "#006400"),
+        ("Verde prado", "#7CFC00"),
+        ("Verde primavera", "#00FF7F"),
+        ("Verde primavera medio", "#00FA9A"),
+        ("Verde pálido", "#98FB98"),
+        ("Violeta", "#EE82EE"),
+        ("Violeta cardo", "#D8BFD8"),
+        ("Violeta oscuro", "#9400D3"),
+        ("Violeta sonrojado pálido", "#DB7093"),
+        ("Índigo", "#4B0082"),
+    ))
+
+    safe_colors = (
+        "negro", "budeos", "verde", "rojo",
+        "violeta", "verde azulado", "azul", "plata",
+        "gris", "amarilo", "fucsia", "cian", "blanco",
+    )
diff --git a/faker/providers/color/fr_FR/__init__.py b/faker/providers/color/fr_FR/__init__.py
index 261201b1..b46314fc 100644
--- a/faker/providers/color/fr_FR/__init__.py
+++ b/faker/providers/color/fr_FR/__init__.py
@@ -65,7 +65,7 @@ class Provider(ColorProvider):
         ("Beige antique", "#FAEBD7"),
         ("Beige papaye", "#FFEFD5"),
         ("Amande", "#FFEBCD"),
-        ("Bisque", "#ffe4c4"),
+        ("Bisque", "#FFE4C4"),
         ("Beige pêche", "#FFDAB9"),
         ("Beige mocassin", "#FFE4B5"),
         ("Jaune blanc navaro", "#FFDEAD"),
diff --git a/faker/providers/color/hy_AM/__init__.py b/faker/providers/color/hy_AM/__init__.py
index 2dfa2cdb..65fa5cc6 100644
--- a/faker/providers/color/hy_AM/__init__.py
+++ b/faker/providers/color/hy_AM/__init__.py
@@ -37,7 +37,7 @@ class Provider(ColorProvider):
         ("Գունատ փիրուզագույն", "#AFEEEE"),
         ("Գրասենյակային կանաչ", "#008000"),
         ("Դարչնագույն ավազ", "#F4A460"),
-        ("Դարչնագույն", "#964b00"),
+        ("Դարչնագույն", "#964B00"),
         ("Դեղին", "#FFFF00"),
         ("Դեղձի կրեմ", "#FFDAB9"),
         ("Դեղնականաչ", "#9ACD3"),
diff --git a/faker/providers/color/pt_BR/__init__.py b/faker/providers/color/pt_BR/__init__.py
index a3a2d949..593bbb8e 100644
--- a/faker/providers/color/pt_BR/__init__.py
+++ b/faker/providers/color/pt_BR/__init__.py
@@ -50,7 +50,7 @@ class Provider(ColorProvider):
         ("Azul flor de milho", "#6495ED"),
         ("Azul força aérea", "#5D8AA8"),
         ("Azul furtivo", "#1E90FF"),
-        ("Azul manteiga", "#a6aa3e"),
+        ("Azul manteiga", "#A6AA3E"),
         ("Azul marinho", "#120A8F"),
         ("Azul médio", "#0000CD"),
         ("Azul meia-noite", "#191970"),
@@ -152,7 +152,7 @@ class Provider(ColorProvider):
         ("Marrom claro", "#A52A2A"),
         ("Marrom rosado", "#BC8F8F"),
         ("Marrom sela", "#8B4513"),
-        ("Marrom", "#964b00"),
+        ("Marrom", "#964B00"),
         ("Milho Claro", "#FFF8DC"),
         ("Milho", "#FBEC5D"),
         ("Mocassim", "#FFE4B5"),


Test patch:
diff --git a/tests/providers/test_address.py b/tests/providers/test_address.py
index 66114721..e99dfc0d 100644
--- a/tests/providers/test_address.py
+++ b/tests/providers/test_address.py
@@ -337,6 +337,10 @@ class TestEnGB(unittest.TestCase):
         for _ in range(100):
             assert isinstance(parse_uk_postcode(self.fake.postcode()), tuple)
 
+    def test_county(self):
+        county = self.fake.county()
+        assert isinstance(county, str)
+
 
 class TestEnUS(unittest.TestCase):
     """ Tests addresses in the en_US locale """
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
index a6cc524d..2ed83dee 100644
--- a/tests/providers/test_bank.py
+++ b/tests/providers/test_bank.py
@@ -110,3 +110,19 @@ class TestPtPt(unittest.TestCase):
     def test_iban(self):
         iban = self.fake.iban()
         assert re.match(r"PT\d{21}", iban)
+
+
+class TestEsES(unittest.TestCase):
+    """Tests the bank provider for es_ES locale"""
+
+    def setUp(self):
+        self.fake = Faker('es_ES')
+        Faker.seed(0)
+
+    def test_bban(self):
+        bban = self.fake.bban()
+        assert re.match(r"\d{20}", bban)
+
+    def test_iban(self):
+        iban = self.fake.iban()
+        assert re.match(r"ES\d{22}", iban)
diff --git a/tests/providers/test_color.py b/tests/providers/test_color.py
index a126f572..1c673864 100644
--- a/tests/providers/test_color.py
+++ b/tests/providers/test_color.py
@@ -7,6 +7,7 @@ from re import search
 
 from faker import Faker
 from faker.providers.color import RandomColor
+from faker.providers.color.es_ES import Provider as EsEsProvider
 from faker.providers.color.fa_IR import Provider as FaIrProvider
 from faker.providers.color.hy_AM import Provider as HyAmProvider
 
@@ -285,3 +286,21 @@ class TestFaIr(unittest.TestCase):
         safe_color_name = self.fake.safe_color_name()
         assert isinstance(safe_color_name, str)
         assert safe_color_name in FaIrProvider.safe_colors
+
+
+class TestEsES(unittest.TestCase):
+    """ Tests colors in the es_ES locale """
+
+    def setUp(self):
+        self.fake = Faker('es_ES')
+        Faker.seed(0)
+
+    def test_color_name(self):
+        color_name = self.fake.color_name()
+        assert isinstance(color_name, str)
+        assert color_name in EsEsProvider.all_colors.keys()
+
+    def test_safe_color_name(self):
+        safe_color_name = self.fake.safe_color_name()
+        assert isinstance(safe_color_name, str)
+        assert safe_color_name in EsEsProvider.safe_colors