Skip to content

Commit f595fb2

Browse files
othmane099othmane099
andauthored
Add currency providers for ar_DZ and fr_DZ locales (#2349)
* add currency provider for fr_DZ locale * add currency provider for ar_DZ locale --------- Co-authored-by: othmane099 <othmabe99@gmail.com>
1 parent 0c2aef9 commit f595fb2

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .. import Provider as CurrencyProvider
2+
3+
4+
class Provider(CurrencyProvider):
5+
# source: https://ar.wikipedia.org/wiki/دينار_جزائري
6+
price_formats = ["#,##", "%#,##", "%##,##", "% ###,##", "%# ###,##"]
7+
8+
def pricetag(self) -> str:
9+
return self.numerify(self.random_element(self.price_formats)) + "\N{NO-BREAK SPACE}دج"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .. import Provider as CurrencyProvider
2+
3+
4+
class Provider(CurrencyProvider):
5+
# source: https://fr.wikipedia.org/wiki/Dinar_alg%C3%A9rien
6+
price_formats = ["#,##", "%#,##", "%##,##", "% ###,##", "%# ###,##"]
7+
8+
def pricetag(self) -> str:
9+
return self.numerify(self.random_element(self.price_formats)) + "\N{NO-BREAK SPACE}DA"

tests/providers/test_currency.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
import pytest
66

77

8+
class TestArDz:
9+
"""Test ar_DZ currency provider"""
10+
11+
num_samples = 100
12+
13+
@classmethod
14+
def setup_class(cls):
15+
from faker.providers.currency.ar_DZ import Provider as ArDzCurrencyProvider
16+
17+
cls.provider = ArDzCurrencyProvider
18+
19+
def test_pricetag(self, faker, num_samples):
20+
for _ in range(num_samples):
21+
pricetag = faker.pricetag()
22+
assert isinstance(pricetag, str)
23+
assert pricetag.endswith("\N{NO-BREAK SPACE}دج")
24+
25+
826
class TestAzAz:
927
"""Test az_AZ currency provider"""
1028

@@ -342,6 +360,24 @@ def test_pricetag(self, faker, num_samples):
342360
assert isinstance(pricetag, str)
343361

344362

363+
class TestFrDz:
364+
"""Test fr_DZ currency provider"""
365+
366+
num_samples = 100
367+
368+
@classmethod
369+
def setup_class(cls):
370+
from faker.providers.currency.fr_DZ import Provider as FrDzCurrencyProvider
371+
372+
cls.provider = FrDzCurrencyProvider
373+
374+
def test_pricetag(self, faker, num_samples):
375+
for _ in range(num_samples):
376+
pricetag = faker.pricetag()
377+
assert isinstance(pricetag, str)
378+
assert pricetag.endswith("\N{NO-BREAK SPACE}DA")
379+
380+
345381
class TestFrFr:
346382
"""Test fr_FR currency provider"""
347383

0 commit comments

Comments
 (0)