Esempio n. 1
0
 def test_round_to_integer(self):
     # Setup
     record = models.MoneyModel(price=Money(10.1, 'EUR'))
     self.column = tables.MoneyColumn(decimals=0)
     # Test
     text = self.column.render(record.price, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10 €', text)
Esempio n. 2
0
 def test_force_decimal_places(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     column = tables.MoneyColumn(decimals=1, )
     # Test
     text = column.render(record.price, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10.0 €', text)
Esempio n. 3
0
 def test_target_currency_and_not_rate(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     self.column = tables.MoneyColumn(target_currency='USD', )
     # Test
     text = self.column.render(record.price, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10.00000 €', text)
Esempio n. 4
0
 def test_money_field_not_use_symbol(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     self.column = tables.MoneyColumn(include_symbol=False, )
     # Test
     text = self.column.render(record.price, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10.00000', text)
Esempio n. 5
0
 def test_money_field(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     self.column = tables.MoneyColumn()
     # Test
     text = self.column.render(record.price, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10.00000 €', text)
Esempio n. 6
0
 def test_decimal_annotation(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     record.as_decimal = Decimal('10')
     self.column = tables.MoneyColumn(
         currency_field='price_currency',
         decimals=5,
     )
     # Test
     text = self.column.render(record.as_decimal, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10.00000 €', text)
Esempio n. 7
0
 def test_force_locale_annotation(self):
     # Setup
     record = models.MoneyModel(price=Money(10, 'EUR'))
     record.as_int = 10
     column = tables.MoneyColumn(
         locale='fr_FR',
         currency_field='price_currency',
     )
     # Test
     text = column.render(record.as_int, record)
     self.assertIsInstance(text, str)
     self.assertEqual('10,00 €', text)