Fixing currency functions for german and french. Adding Currency_Forms for DE, FR and NL. (#247)

* Fix currency function for French. Adding Currency_Forms.

* Fix currency function for German. Adding Currency_Forms.

* Move FR_DZ to new currency functions, too.

* Fix tests

* Add more currency options for dutch.

* Add more tests for German, Dutch and French currencies.
This commit is contained in:
Sarah Beranek
2019-04-12 01:07:44 +02:00
committed by Ernesto Rodriguez Ortiz
parent 18194b52ef
commit a869745813
10 changed files with 211 additions and 114 deletions

View File

@@ -118,26 +118,34 @@ TEST_CASES_ORDINAL_NUM = (
(1000000, '1000000me')
)
TEST_CASES_TO_CURRENCY = (
(1, 'un euro'),
(2, 'deux euros'),
(8, 'huit euros'),
(12, 'douze euros'),
(21, 'vingt et un euros'),
TEST_CASES_TO_CURRENCY_EUR = (
(1.00, 'un euro et zéro centimes'),
(2.01, 'deux euros et un centime'),
(8.10, 'huit euros et dix centimes'),
(12.26, 'douze euros et vingt-six centimes'),
(21.29, 'vingt et un euros et vingt-neuf centimes'),
(81.25, 'quatre-vingt-un euros et vingt-cinq centimes'),
(81.2, 'quatre-vingt-un euros et vingt centimes'),
(100, 'cent euros'),
(100.00, 'cent euros et zéro centimes'),
)
TEST_CASES_TO_CURRENCY_OLD = (
(1, 'un franc'),
(2, 'deux francs'),
(8, 'huit francs'),
(12, 'douze francs'),
(21, 'vingt et un francs'),
TEST_CASES_TO_CURRENCY_FRF = (
(1.00, 'un franc et zéro centimes'),
(2.01, 'deux francs et un centime'),
(8.10, 'huit francs et dix centimes'),
(12.27, 'douze francs et vingt-sept centimes'),
(21.29, 'vingt et un francs et vingt-neuf centimes'),
(81.25, 'quatre-vingt-un francs et vingt-cinq centimes'),
(81.2, 'quatre-vingt-un francs et vingt centimes'),
(100, 'cent francs'),
(100.00, 'cent francs et zéro centimes'),
)
TEST_CASES_TO_CURRENCY_USD = (
(1.00, 'un dollar et zéro cents'),
(2.01, 'deux dollars et un cent'),
(8.10, 'huit dollars et dix cents'),
(12.26, 'douze dollars et vingt-six cents'),
(21.29, 'vingt et un dollars et vingt-neuf cents'),
(81.25, 'quatre-vingt-un dollars et vingt-cinq cents'),
(100.00, 'cent dollars et zéro cents'),
)
@@ -175,16 +183,23 @@ class Num2WordsENTest(TestCase):
test[1]
)
def test_currency(self):
for test in TEST_CASES_TO_CURRENCY:
def test_currency_eur(self):
for test in TEST_CASES_TO_CURRENCY_EUR:
self.assertEqual(
num2words(test[0], lang='fr', to='currency'),
num2words(test[0], lang='fr', to='currency', currency='EUR'),
test[1]
)
def test_currency_old(self):
for test in TEST_CASES_TO_CURRENCY_OLD:
def test_currency_frf(self):
for test in TEST_CASES_TO_CURRENCY_FRF:
self.assertEqual(
num2words(test[0], lang='fr', to='currency', old=True),
num2words(test[0], lang='fr', to='currency', currency='FRF'),
test[1]
)
def test_currency_usd(self):
for test in TEST_CASES_TO_CURRENCY_USD:
self.assertEqual(
num2words(test[0], lang='fr', to='currency', currency='USD'),
test[1]
)