Exemplo n.º 1
0
 def _associate_rates(self, name, rates):
     user = getattr(self, name)
     for item in rates:
         rate = Rate()
         rate.description = 'Test Rate'
         rate.amount = item.amount
         rate.days = item.days
         rate.user = user
         rate.save()
Exemplo n.º 2
0
 def test_calculate_negative_amount_per_day(self):
     instance = Rate()
     instance.description = 'Test Rate'
     instance.amount = Decimal(-10)
     instance.days = 11
     instance.user = User.objects.create_user('*****@*****.**')
     instance.save()
     instance.refresh_from_db()
     self.assertEqual(instance.amount_per_day, to_decimal(-0.909))
Exemplo n.º 3
0
 def test_calculate_negative_amount_per_day(self):
     instance = Rate()
     instance.description = 'Test Rate'
     instance.amount = Decimal(-10)
     instance.days = 11
     instance.user = User.objects.create_user('*****@*****.**')
     instance.save()
     instance.refresh_from_db()
     self.assertEqual(instance.amount_per_day, to_decimal(-0.909))
Exemplo n.º 4
0
 def _associate_rates(self, name, rates):
     user = getattr(self, name)
     for item in rates:
         rate = Rate()
         rate.description = 'Test Rate'
         rate.amount = item.amount
         rate.days = item.days
         rate.user = user
         rate.save()
Exemplo n.º 5
0
    def test_total_something(self):
        instance = Rate()
        instance.description = 'Test Rate'
        instance.amount = Decimal(10)
        instance.days = 10
        instance.user = User.objects.create_user('*****@*****.**')
        instance.save()

        actual = Rate.objects.total()
        self.assertEqual(actual, to_decimal(1))
Exemplo n.º 6
0
    def test_total_something(self):
        instance = Rate()
        instance.description = 'Test Rate'
        instance.amount = Decimal(10)
        instance.days = 10
        instance.user = User.objects.create_user('*****@*****.**')
        instance.save()

        actual = Rate.objects.total()
        self.assertEqual(actual, to_decimal(1))
Exemplo n.º 7
0
    def create_rate(self, description ="Test Rate", days=10, amount = 10):
        usr = User.objects.create_user('*****@*****.**')

        rate = Rate()
        rate.description = description
        rate.amount = Decimal(amount)
        rate.days = days
        rate.user = usr

        rate.save()
        rate.refresh_from_db()

        return rate