import jingrow
from jingrow import format
from jingrow.tests.utils import JingrowTestCase


class TestFormatter(JingrowTestCase):
	def test_currency_formatting(self):
		df = jingrow._dict({"fieldname": "amount", "fieldtype": "Currency", "options": "currency"})

		pg = jingrow._dict({"amount": 5})
		jingrow.db.set_default("currency", "INR")

		# if currency field is not passed then default currency should be used.
		self.assertEqual(format(100000, df, pg, format="#,###.##"), "₹ 100,000.00")

		pg.currency = "USD"
		self.assertEqual(format(100000, df, pg, format="#,###.##"), "$ 100,000.00")

		jingrow.db.set_default("currency", None)
