Repository: joke2k/faker
Pull request #1971 (2024-01-10 07:38:34)

Add fa_IR localization for currency provider
### Add ``fa_IR`` localization in ``currency`` provider

``IRR`` is Iran main currency and looks something like ``1,000,000,000 IRR``,
This PR will add better localize faker for Iran currency.

parsariyahi: This PR is related to #1970 

Patch:
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 5e6f3d77..541d2d9d 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 22.1.0
+current_version = 22.3.0
 files = VERSION faker/__init__.py docs/conf.py
 commit = True
 tag = True
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c2cd244..96e0c249 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
 ## Changelog
 
+
+### [v22.3.0 - 2024-01-19](https://github.com/joke2k/faker/compare/v22.2.0...v22.3.0)
+
+* add bank provider for `uk_UA`. Thanks @SanderFtn.
+
+### [v22.2.0 - 2024-01-10](https://github.com/joke2k/faker/compare/v22.1.0...v22.2.0)
+
+* Add bank provider for `cs_CZ`. Thanks @george0st.
+
 ### [v22.1.0 - 2024-01-08](https://github.com/joke2k/faker/compare/v22.0.0...v22.1.0)
 
 * Add support for multiple file systems path rules. Thanks @parsariyahi.
diff --git a/VERSION b/VERSION
index ee5c2446..8326e27f 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-22.1.0
+22.3.0
diff --git a/docs/conf.py b/docs/conf.py
index 9529bdc0..dc8376ab 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -51,9 +51,9 @@ copyright = "2014, Daniele Faraglia"
 # built documents.
 #
 # The short X.Y version.
-version = "22.1.0"
+version = "22.3.0"
 # The full version, including alpha/beta/rc tags.
-release = "22.1.0"
+release = "22.3.0"
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/faker/__init__.py b/faker/__init__.py
index 46d0f344..818237e5 100644
--- a/faker/__init__.py
+++ b/faker/__init__.py
@@ -2,6 +2,6 @@ from faker.factory import Factory
 from faker.generator import Generator
 from faker.proxy import Faker
 
-VERSION = "22.1.0"
+VERSION = "22.3.0"
 
 __all__ = ("Factory", "Generator", "Faker")
diff --git a/faker/providers/address/en_US/__init__.py b/faker/providers/address/en_US/__init__.py
index dab1b468..85bbb946 100644
--- a/faker/providers/address/en_US/__init__.py
+++ b/faker/providers/address/en_US/__init__.py
@@ -508,7 +508,7 @@ class Provider(AddressProvider):
         """
         :returns: A random two-letter USPS postal code
 
-        By default, the resulting code may abbreviate any of the fity states,
+        By default, the resulting code may abbreviate any of the fifty states,
         five US territories, or three freely-associating sovereign states.
 
         :param include_territories: If True, territories will be included.
diff --git a/faker/providers/bank/cs_CZ/__init__.py b/faker/providers/bank/cs_CZ/__init__.py
new file mode 100644
index 00000000..7ea79ab2
--- /dev/null
+++ b/faker/providers/bank/cs_CZ/__init__.py
@@ -0,0 +1,11 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    """Implement bank provider for ``cs_CZ`` locale.
+
+    https://www.mbank.cz/informace-k-produktum/info/ucty/cislo-uctu-iban.html
+    """
+
+    bban_format = "####################"
+    country_code = "CZ"
diff --git a/faker/providers/bank/uk_UA/__init__.py b/faker/providers/bank/uk_UA/__init__.py
new file mode 100644
index 00000000..3b53dd45
--- /dev/null
+++ b/faker/providers/bank/uk_UA/__init__.py
@@ -0,0 +1,11 @@
+from .. import Provider as BankProvider
+
+
+class Provider(BankProvider):
+    """Implement bank provider for ``uk_UA`` locale.
+    Source for rules for bban format:
+    https://bank.gov.ua/en/iban
+    """
+
+    bban_format = "#" * 27
+    country_code = "UA"
diff --git a/faker/providers/currency/fa_IR/__init__.py b/faker/providers/currency/fa_IR/__init__.py
new file mode 100644
index 00000000..747313be
--- /dev/null
+++ b/faker/providers/currency/fa_IR/__init__.py
@@ -0,0 +1,8 @@
+from .. import Provider as CurrencyProvider
+
+
+class Provider(CurrencyProvider):
+    price_formats = ["###,###,000","#,###,000,000", "%,###,###,###,###", "%,###,###,###,000,000"]
+
+    def pricetag(self) -> str:
+        return self.numerify(self.random_element(self.price_formats)) + "\uFDFC"


Test patch:
diff --git a/tests/providers/test_bank.py b/tests/providers/test_bank.py
index cf065af3..fe37cb5a 100644
--- a/tests/providers/test_bank.py
+++ b/tests/providers/test_bank.py
@@ -4,6 +4,7 @@ import pytest
 
 from faker.providers.bank import Provider as BankProvider
 from faker.providers.bank.az_AZ import Provider as AzAzBankProvider
+from faker.providers.bank.cs_CZ import Provider as CsCZBankProvider
 from faker.providers.bank.de_CH import Provider as DeChBankProvider
 from faker.providers.bank.el_GR import Provider as ElGrBankProvider
 from faker.providers.bank.en_GB import Provider as EnGbBankProvider
@@ -21,6 +22,7 @@ from faker.providers.bank.pl_PL import Provider as PlPlBankProvider
 from faker.providers.bank.pt_PT import Provider as PtPtBankProvider
 from faker.providers.bank.th_TH import Provider as ThThBankProvider
 from faker.providers.bank.tr_TR import Provider as TrTrBankProvider
+from faker.providers.bank.uk_UA import Provider as UkUaBankProvider
 
 
 def is_valid_iban(iban):
@@ -57,6 +59,21 @@ class TestAzAz:
             assert bank in AzAzBankProvider.banks
 
 
+class TestCsCz:
+    """Test cs_CZ bank provider"""
+
+    def test_bban(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r"\d{20}", faker.bban())
+
+    def test_iban(self, faker, num_samples):
+        for _ in range(num_samples):
+            iban = faker.iban()
+            assert is_valid_iban(iban)
+            assert iban[:2] == CsCZBankProvider.country_code
+            assert re.fullmatch(r"\d{2}\d{20}", iban[2:])
+
+
 class TestNoNo:
     """Test no_NO bank provider"""
 
@@ -120,6 +137,21 @@ class TestPlPl:
             assert re.fullmatch(r"\d{2}\d{24}", iban[2:])
 
 
+class TestUkUa:
+    """Test uk_UA bank provider"""
+
+    def test_bban(self, faker, num_samples):
+        for _ in range(num_samples):
+            assert re.fullmatch(r"\d{27}", faker.bban())
+
+    def test_iban(self, faker, num_samples):
+        for _ in range(num_samples):
+            iban = faker.iban()
+            assert is_valid_iban(iban)
+            assert iban[:2] == UkUaBankProvider.country_code
+            assert re.fullmatch(r"\d{2}\d{27}", iban[2:])
+
+
 class TestEnGb:
     """Test en_GB bank provider"""
 
diff --git a/tests/providers/test_currency.py b/tests/providers/test_currency.py
index 751117e7..862a5081 100644
--- a/tests/providers/test_currency.py
+++ b/tests/providers/test_currency.py
@@ -247,6 +247,23 @@ class TestEsEs:
             assert isinstance(pricetag, str)
 
 
+class TestFaIr:
+    """Test fa_IR currency provider"""
+
+    num_samples = 100
+
+    @classmethod
+    def setup_class(cls):
+        from faker.providers.currency.fa_IR import Provider as FaIrCurrencyProvider
+
+        cls.provider = FaIrCurrencyProvider
+
+    def test_pricetag(self, faker, num_samples):
+        for _ in range(num_samples):
+            pricetag = faker.pricetag()
+            assert isinstance(pricetag, str)
+
+
 class TestFrCa:
     """Test fr_CA currency provider"""