Repository: joke2k/faker
Pull request #1199 (2020-06-15 23:40:39)

Add es_ES currency provider.
### What does this changes

Add Spanish currency names to `currency` provider.

fcurella: Thank you! ✨ 

Patch:
diff --git a/faker/providers/currency/es_ES/__init__.py b/faker/providers/currency/es_ES/__init__.py
new file mode 100644
index 00000000..e7f9006b
--- /dev/null
+++ b/faker/providers/currency/es_ES/__init__.py
@@ -0,0 +1,171 @@
+from .. import Provider as CurrencyProvider
+
+
+class Provider(CurrencyProvider):
+    # Format: (code, name)
+    currencies = (
+        ("AED", "Dírham de los Emiratos Árabes Unidos"),
+        ("AFN", "Afghaní"),
+        ("ALL", "Lek albanés"),
+        ("AMD", "Dram armenio"),
+        ("ANG", "Florín de las Antillas Holandesas"),
+        ("AOA", "Kwanza angoleño"),
+        ("ARS", "Peso argentino"),
+        ("AUD", "Dólar australiano"),
+        ("AWG", "Florín arubeño"),
+        ("AZN", "Manat azerbaiyano"),
+        ("BAM", "Marco bosnioherzegovino"),
+        ("BBD", "Dólar barbadense"),
+        ("BDT", "Taka bangladesí"),
+        ("BGN", "Lev búlgaro"),
+        ("BHD", "Dinar bahreiní"),
+        ("BIF", "Franco burundés"),
+        ("BMD", "Dólar de Bermudas"),
+        ("BND", "Dólar bruneano"),
+        ("BOB", "Boliviano"),
+        ("BRL", "Real brasileño"),
+        ("BSD", "Dólar bahameño"),
+        ("BTN", "Ngultrum butanés"),
+        ("BWP", "Pula de Botswana"),
+        ("BYR", "Rublio bielurruso"),
+        ("BZD", "Dólar beliceño"),
+        ("CAD", "Dólar canadiense"),
+        ("CDF", "Franco congolés"),
+        ("CHF", "Franco suizo"),
+        ("CLP", "Peso chileno"),
+        ("CNY", "Yuan"),
+        ("COP", "Peso colombiano"),
+        ("CRC", "Colón costarricense"),
+        ("CUC", "Peso cubano convertible"),
+        ("CUP", "Peso subano"),
+        ("CVE", "Escudo de Cabo Verde"),
+        ("CZK", "Corona checa"),
+        ("DJF", "Franco yibutiano"),
+        ("DKK", "Corona danesa"),
+        ("DOP", "Peso dominicano"),
+        ("DZD", "Dinar argelino"),
+        ("EGP", "Libra egipcia"),
+        ("ERN", "Nafka"),
+        ("ETB", "Bir de Etiopía"),
+        ("EUR", "Euro"),
+        ("FJD", "Dólar fiyiano"),
+        ("FKP", "Libra de las islas Falkland"),
+        ("GBP", "Libra esterlina"),
+        ("GEL", "Larí georgiano"),
+        ("GGP", "Libra de Guernsey"),
+        ("GHS", "Cedi"),
+        ("GIP", "Libra de Gibraltar"),
+        ("GMD", "Dalasi"),
+        ("GNF", "Franco guineano"),
+        ("GTQ", "Quetzal guatemalteco"),
+        ("GYD", "Dólar guyanés"),
+        ("HKD", "Dólar hongkonés"),
+        ("HNL", "Lempira hondureño"),
+        ("HRK", "Kuna croata"),
+        ("HTG", "Gourde haitiano"),
+        ("HUF", "Forinto húngaro"),
+        ("IDR", "Rupia indonesia"),
+        ("ILS", "Séquel israelí"),
+        ("NIS", "Nuevo Séquel israelí"),
+        ("IMP", "Libra manesa"),
+        ("INR", "Rupia india"),
+        ("IQD", "Dinar iraquí"),
+        ("IRR", "Rial iraní"),
+        ("ISK", "Corona islandesa"),
+        ("JEP", "Libra de Jersey"),
+        ("JMD", "Dólar jamaicano"),
+        ("JOD", "Dinar jordano"),
+        ("JPY", "Yen japonés"),
+        ("KES", "Chelín keniano"),
+        ("KGS", "Som kirguís"),
+        ("KHR", "Riel camboyano"),
+        ("KMF", "Franco comorense"),
+        ("KPW", "Won norcoreano"),
+        ("KRW", "Krahn Occidental"),
+        ("KWD", "Dinar kuwaití"),
+        ("KYD", "Dólar de las islas Cayman"),
+        ("KZT", "Tenge kazako"),
+        ("LAK", "Kip laosiano"),
+        ("LBP", "Libra libanesa"),
+        ("LKR", "Rupia esrilanquesa"),
+        ("LRD", "Dólar liberiano"),
+        ("LSL", "Loti lesothense"),
+        ("LTL", "Litas lituana"),
+        ("LYD", "Dinar libio"),
+        ("MAD", "Dirham marroquí"),
+        ("MDL", "Leu moldavo"),
+        ("MGA", "Ariary malgache"),
+        ("MKD", "Denar normacedonio"),
+        ("MMK", "Kyat birmano"),
+        ("MNT", "Tugrik mongol"),
+        ("MOP", "Pataca macaense"),
+        ("MRO", "Ouguiya mauritano"),
+        ("MUR", "Rupia mauritana"),
+        ("MVR", "Rupia de Maldivas"),
+        ("MWK", "Kwacha malauí"),
+        ("MXN", "Peso mexicano"),
+        ("MYR", "Ringgit"),
+        ("MZN", "Metical mozambiqueño"),
+        ("NAD", "Dólar namibio"),
+        ("NGN", "Naira nigeriano"),
+        ("NIO", "Córdoba nicaragüense"),
+        ("NOK", "Corona noruega"),
+        ("NPR", "Rupia nepalí"),
+        ("NZD", "Dólar neozelandés"),
+        ("OMR", "Rial omaní"),
+        ("PAB", "Balboa panameño"),
+        ("PEN", "Sol peruano"),
+        ("PGK", "Kina"),
+        ("PHP", "Peso filipino"),
+        ("PKR", "Rupia pakistaní"),
+        ("PLN", "Złoty polaco"),
+        ("PYG", "Guaraní paraguayo"),
+        ("QAR", "Riyal catarí"),
+        ("RON", "Leu rumano"),
+        ("RSD", "Dinar serbio"),
+        ("RUB", "Rublo ruso"),
+        ("RWF", "Franco ruandés"),
+        ("SAR", "Riyal saudí"),
+        ("SBD", "Dólar de las islas Solomon"),
+        ("SCR", "Rupia seychellense"),
+        ("SDG", "Libra sudanesa"),
+        ("SEK", "Corona sueca"),
+        ("SGD", "Dólar de Singapur"),
+        ("SHP", "Libra de Santa Elena"),
+        ("SLL", "Leona"),
+        ("SOS", "Chelín somalí"),
+        ("SPL", "Luigino"),
+        ("SRD", "Dólar surinamés"),
+        ("STD", "Dobra santotomense"),
+        ("SVC", "Colón salvadoreño"),
+        ("SYP", "Libra siria"),
+        ("SZL", "Lilangeni"),
+        ("THB", "Baht tailandés"),
+        ("TJS", "Somoni tayiko"),
+        ("TMT", "Manat turcomano"),
+        ("TND", "Dinar tunecino"),
+        ("TOP", "Pa'anga tongano"),
+        ("TRY", "Lira turca"),
+        ("TTD", "Dólar de Trinidad and Tobago"),
+        ("TVD", "Dólar tuvaluano"),
+        ("TWD", "Nuevo dólar taiwanés"),
+        ("TZS", "Chelín tanzano"),
+        ("UAH", "Grivna ucraniano"),
+        ("UGX", "Chelín ugandés"),
+        ("USD", "Dólar de Estados Unidos"),
+        ("UYU", "Peso uruguayo"),
+        ("UZS", "Soʻm Uzbekistani"),
+        ("VEF", "Bolívar venezolano"),
+        ("VND", "Đồng vietnamita"),
+        ("VUV", "Vanuatu vatu"),
+        ("WST", "Tālā samoano"),
+        ("XAF", "Franco centro africano"),
+        ("XCD", "Dólar del Caribe Oriental"),
+        ("XDR", "Derechos especiales de giro"),
+        ("XOF", "Franco de África occidental"),
+        ("XPF", "Franco CFP"),
+        ("YER", "Rial yemení"),
+        ("ZAR", "Rand sudafricano"),
+        ("ZMW", "Kwacha zambiano"),
+        ("ZWD", "Dólar zimbabuense"),
+    )


Test patch:
diff --git a/tests/providers/test_currency.py b/tests/providers/test_currency.py
index 9432b7a4..d8823169 100644
--- a/tests/providers/test_currency.py
+++ b/tests/providers/test_currency.py
@@ -88,3 +88,25 @@ class TestRuRu:
         for _ in range(num_samples):
             name = faker.currency_name()
             assert isinstance(name, str) and name in self.currency_names
+
+
+class TestEsEs:
+    """Test es_ES currency provider"""
+    num_samples = 100
+
+    @classmethod
+    def setup_class(cls):
+        from faker.providers.currency.es_ES import Provider as EsEsCurrencyProvider
+        cls.provider = EsEsCurrencyProvider
+        cls.currencies = cls.provider.currencies
+        cls.currency_codes, cls.currency_names = tuple(zip(*cls.currencies))
+
+    def test_currency(self, faker, num_samples):
+        for _ in range(num_samples):
+            cur = faker.currency()
+            assert cur in self.currencies
+
+    def test_currency_name(self, faker, num_samples):
+        for _ in range(num_samples):
+            name = faker.currency_name()
+            assert name in self.currency_names