import influxframework
from influxframework import format
from influxframework.tests.utils import InfluxFrameworkTestCase


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

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

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

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

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