Repository: joke2k/faker
Pull request #1300 (2020-10-07 23:41:11)

Add mdgen to community-providers
### What does this changes

I would like to add my community provider- `fake.post` to the docs.

### What was wrong

Initially this project was conceived since I needed to populate my django models with fake data. Faker doesn't provide any way to create markdown formatted fake data, and I decided to extend it.

This is in regards to #1299.

I am a bit unsure where to make my PR to. Do I make it to the `master` branch?


Patch:
diff --git a/.gitignore b/.gitignore
index ad8222c2..f3259eea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,3 +52,4 @@ nosetests.xml
 *.iml
 *.ipr
 venv/
+.vscode
diff --git a/docs/communityproviders.rst b/docs/communityproviders.rst
index 6d103a1b..d027ed14 100644
--- a/docs/communityproviders.rst
+++ b/docs/communityproviders.rst
@@ -22,6 +22,9 @@ Here's a list of Providers written by the community:
 | Vehicle       | Fake vehicle information | `faker_vehicle`_                 |
 |               | includes Year Make Model |                                  |
 +---------------+--------------------------+----------------------------------+
+| Posts         | Fake posts in markdown   | `mdgen`_                         |
+|               | format                   |                                  |
++---------------+--------------------------+----------------------------------+
 
 If you want to add your own provider to this list, please submit a Pull Request to our `repo`_.
 
@@ -41,3 +44,4 @@ In order to be inlcuded, your provider must satisfy these requirement:
 .. _faker_credit_score: https://pypi.org/project/faker-credit-score/
 .. _faker_microservice: https://pypi.org/project/faker-microservice/
 .. _faker_vehicle: https://pypi.org/project/faker-vehicle/
+.. _mdgen: https://pypi.org/project/mdgen/
diff --git a/faker/providers/currency/sv_SE/__init__.py b/faker/providers/currency/sv_SE/__init__.py
new file mode 100644
index 00000000..69919686
--- /dev/null
+++ b/faker/providers/currency/sv_SE/__init__.py
@@ -0,0 +1,178 @@
+from .. import Provider as CurrencyProvider
+
+# Names taken from https://www.iban.se/currency-codes
+
+
+class Provider(CurrencyProvider):
+    # Format: (code, name)
+    currencies = (
+        ("AED", "UAE Dirham"),
+        ("AFN", "Afghani"),
+        ("ALL", "Lek"),
+        ("AMD", "Armenisk Dram"),
+        ("ANG", "Gulden från Nederländska Antillerna"),
+        ("AOA", "Kwanza"),
+        ("ARS", "Argentinsk Peso"),
+        ("AUD", "Australisk Dollar"),
+        ("AWG", "Arubisk Florin"),
+        ("AZN", "Azerbajdzjansk Manat"),
+        ("BAM", "Konvertibel Mark"),
+        ("BBD", "Barbadosdollar"),
+        ("BDT", "Taka"),
+        ("BGN", "Bulgarisk Lev"),
+        ("BHD", "Bahraini Dinar"),
+        ("BIF", "Burundi-franc"),
+        ("BMD", "Bermuda-dollar"),
+        ("BND", "Brunei-dollar"),
+        ("BOB", "Boliviano"),
+        ("BOV", "Mvdol"),
+        ("BRL", "Brasilisk Real"),
+        ("BSD", "Bahamasdollar"),
+        ("BTN", "Ngultrum"),
+        ("BWP", "Pula"),
+        ("BYR", "Vitrysk Rubel"),
+        ("BZD", "Belize-dollar"),
+        ("CAD", "Kanadensisk Dollar"),
+        ("CDF", "Kongolesisk Franc"),
+        ("CHE", "WIR Euro"),
+        ("CHF", "Schweizerfranc"),
+        ("CHW", "WIR Franc"),
+        ("CLF", "Unidad de Fomento"),
+        ("CLP", "Chilensk Peso"),
+        ("CNY", "Yuan Renminbi"),
+        ("COP", "Colombiansk Peso"),
+        ("COU", "Unidad de Valor Real"),
+        ("CRC", "Costa Ricansk Colon"),
+        ("CUC", "Peso Convertible"),
+        ("CUP", "Kubansk Peso"),
+        ("CVE", "Kap Verde Escudo"),
+        ("CZK", "Tjeckisk Koruna"),
+        ("DJF", "Djibouti-franc"),
+        ("DKK", "Dansk Krone"),
+        ("DOP", "Dominicansk Peso"),
+        ("DZD", "Algerisk Dinar"),
+        ("EGP", "Egyptiskt pund"),
+        ("ERN", "Nakfa"),
+        ("ETB", "Etiopisk Birr"),
+        ("EUR", "Euro"),
+        ("FJD", "Fiji Dollar"),
+        ("FKP", "Pund från Falklandöarna"),
+        ("GBP", "Pund Sterling"),
+        ("GEL", "Lari"),
+        ("GHS", "Ghana Cedi"),
+        ("GIP", "Gibraltar-pund"),
+        ("GMD", "Dalasi"),
+        ("GNF", "Guinea-franc"),
+        ("GTQ", "Quetzal"),
+        ("GYD", "Guyana-dollar"),
+        ("HKD", "Hong Kong-dollar"),
+        ("HNL", "Lempira"),
+        ("HRK", "Kuna"),
+        ("HTG", "Gourde"),
+        ("HUF", "Forint"),
+        ("IDR", "Rupiah"),
+        ("ILS", "Ny Israelisk Shekel"),
+        ("INR", "Indisk Rupie"),
+        ("IQD", "Irakisk Dinar"),
+        ("IRR", "Iransk Rial"),
+        ("ISK", "Isländsk Krona"),
+        ("JMD", "Jamaica-dollar"),
+        ("JOD", "Jordanisk Dinar"),
+        ("JPY", "Yen"),
+        ("KES", "Kenyansk Shilling"),
+        ("KGS", "Som"),
+        ("KHR", "Riel"),
+        ("KMF", "Comoros-franc"),
+        ("KPW", "Nordkoreansk Won"),
+        ("KRW", "Won"),
+        ("KWD", "Kuwaiti Dinar"),
+        ("KYD", "Caymanöar-dollar"),
+        ("KZT", "Tenge"),
+        ("LAK", "Kip"),
+        ("LBP", "Libanesiskt pund"),
+        ("LKR", "Sri Lanka Rupie"),
+        ("LRD", "Liberiansk Dollar"),
+        ("LSL", "Loti"),
+        ("LYD", "Libysk Dinar"),
+        ("MAD", "Marockansk Dirham"),
+        ("MDL", "Moldavisk Leu"),
+        ("MGA", "Malagasy Ariary"),
+        ("MKD", "Denar"),
+        ("MMK", "Kyat"),
+        ("MNT", "Tugrik"),
+        ("MOP", "Pataca"),
+        ("MRO", "Ouguiya"),
+        ("MUR", "Mauritius Rupie"),
+        ("MVR", "Rufiyaa"),
+        ("MWK", "Kwacha"),
+        ("MXN", "Mexikansk Peso"),
+        ("MXV", "Mexikansk Unidad de Inversion (UDI)"),
+        ("MYR", "Malaysisk Ringgit"),
+        ("MZN", "Mozambique Metical"),
+        ("NAD", "Namibia Dollar"),
+        ("NGN", "Naira"),
+        ("NIO", "Cordoba Oro"),
+        ("NOK", "Norsk Krone"),
+        ("NOK", "Norwegian Krone"),
+        ("NPR", "Nepalesisk Rupie"),
+        ("NZD", "Nya Zealand-dollar"),
+        ("OMR", "Rial Omani"),
+        ("PAB", "Balboa"),
+        ("PEN", "Nuevo Sol"),
+        ("PGK", "Kina"),
+        ("PHP", "Filippinsk Peso"),
+        ("PKR", "Pakistansk Rupie"),
+        ("PLN", "Zloty"),
+        ("PYG", "Guarani"),
+        ("QAR", "Qatari Rial"),
+        ("RON", "Rumänsk Leu"),
+        ("RSD", "Serbisk Dinar"),
+        ("RUB", "Rysk Rubel"),
+        ("RWF", "Rwanda Franc"),
+        ("SAR", "Saudi Riyal"),
+        ("SBD", "Dollar från Salomonöarna"),
+        ("SCR", "Seychell-rupie"),
+        ("SDG", "Sudanesiskt pund"),
+        ("SEK", "Svensk Krona"),
+        ("SGD", "Singapore Dollar"),
+        ("SHP", "Saint Helena pund"),
+        ("SLL", "Leone"),
+        ("SOS", "Somalisk Shilling"),
+        ("SRD", "Surinam Dollar"),
+        ("SSP", "Sydsudanesiskt pund"),
+        ("STD", "Dobra"),
+        ("SVC", "El Salvador Colon"),
+        ("SYP", "Syriskt pund"),
+        ("SZL", "Lilangeni"),
+        ("THB", "Baht"),
+        ("TJS", "Somoni"),
+        ("TMT", "Turkmenistansk Ny Manat"),
+        ("TND", "Tunisisk Dinar"),
+        ("TOP", "Pa’anga"),
+        ("TRY", "Turkisk Lira"),
+        ("TTD", "Trinidad och Tobago Dollar"),
+        ("TWD", "Ny Taiwanesisk Dollar"),
+        ("TZS", "Tanzanisk Shilling"),
+        ("UAH", "Hryvnia"),
+        ("UGX", "Uganda Shilling"),
+        ("USD", "US Dollar"),
+        ("USN", "US Dollar (Nästa dag)"),
+        ("UYI", "Uruguay Peso en Unidades Indexadas (URUIURUI)"),
+        ("UYU", "Peso Uruguayo"),
+        ("UZS", "Uzbekistansk Sum"),
+        ("VEF", "Bolivar"),
+        ("VND", "Dong"),
+        ("VUV", "Vatu"),
+        ("WST", "Tala"),
+        ("XAF", "CFA Franc BEAC"),
+        ("XCD", "East Caribbean Dollar"),
+        ("XDR", "SDR (Särskild dragningsrätt)"),
+        ("XOF", "CFA Franc BCEAO"),
+        ("XPF", "CFP Franc"),
+        ("XSU", "Sucre"),
+        ("XUA", "ADB Beräkningsenhet"),
+        ("YER", "Yemeni Rial"),
+        ("ZAR", "Rand"),
+        ("ZMW", "Zambian Kwacha"),
+        ("ZWL", "Zimbabwe Dollar"),
+    )


Test patch:
diff --git a/tests/providers/test_currency.py b/tests/providers/test_currency.py
index d8823169..81bd2220 100644
--- a/tests/providers/test_currency.py
+++ b/tests/providers/test_currency.py
@@ -110,3 +110,25 @@ class TestEsEs:
         for _ in range(num_samples):
             name = faker.currency_name()
             assert name in self.currency_names
+
+
+class TestSvSe:
+    """Test sv_SE currency provider"""
+    num_samples = 100
+
+    @classmethod
+    def setup_class(cls):
+        from faker.providers.currency.sv_SE import Provider as SvSeCurrencyProvider
+        cls.provider = SvSeCurrencyProvider
+        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