Example #1
0
 def test_invalid_default(self):
     with self.assertRaises(TypeError):
         testfield = MoneyField(
             name='testfield',
             decimal_places=2,
             max_digits=8,
             default="1234.00 EUR",
         )
Example #2
0
 def test_both_fixed_currency_and_default_valid(self):
     testfield = MoneyField(
         name='testfield',
         decimal_places=2,
         max_digits=8,
         currency='USD',
         default=Money('1234.00', 'USD'),
     )
Example #3
0
 def test_both_default_and_currency_default(self):
     with self.assertRaises(FieldError):
         testfield = MoneyField(
             name='testfield',
             decimal_places=2,
             max_digits=8,
             currency_default='EUR',
             default=Money('1234.00', 'EUR'),
         )
Example #4
0
 def test_both_fixed_currency_and_currency_choices(self):
     with self.assertRaises(FieldError):
         testfield = MoneyField(
             name='testfield',
             decimal_places=2,
             max_digits=8,
             currency='USD',
             currency_choices=(('USD', 'USD'), ),
         )
Example #5
0
class ChoicesCurrencyModel(models.Model):
    CURRENCY_CHOICES = (
        ('EUR', 'EUR'),
        ('USD', 'USD'),
        ('CNY', 'CNY'),
    )
    CURRENCY_DEFAULT = 'EUR'
    
    name = models.CharField(blank=True, max_length=100)
    price = MoneyField(decimal_places=2, max_digits=12, 
                       currency_choices=CURRENCY_CHOICES,
                       currency_default=CURRENCY_DEFAULT)
Example #6
0
class FixedCurrencyModel(models.Model):
    name = models.CharField(blank=True, max_length=100)
    price = MoneyField(decimal_places=2, max_digits=12, currency='EUR')
Example #7
0
class SomeMoney(models.Model):
    field1 = models.CharField(blank=True, max_length=100)
    field2 = MoneyField(decimal_places=2, max_digits=12)
    field3 = models.CharField(blank=True, max_length=100)
Example #8
0
class FreeCurrencyDefaultAmountModel(models.Model):
    name = models.CharField(blank=True, max_length=100)
    price = MoneyField(decimal_places=2, max_digits=12, 
                       amount_default=Decimal('1234.00'))
Example #9
0
 def test_missing_max_digits(self):
     with self.assertRaises(FieldError) as cm:
         testfield = MoneyField(name='testfield', decimal_places=2)
     self.assertIn('max_digits', cm.exception.args[0])