Beispiel #1
0
class TestAVoucher(TestCase):
    def setUp(self):
        self.voucher = Voucher(start_datetime=START_DATETIME,
                               end_datetime=END_DATETIME)

    def test_is_active_between_start_and_end_dates(self):
        test = datetime.datetime(2011, 6, 10).replace(tzinfo=utc)
        self.assertTrue(self.voucher.is_active(test))

    def test_is_active_on_end_date(self):
        self.assertTrue(self.voucher.is_active(END_DATETIME))

    def test_is_active_on_start_date(self):
        self.assertTrue(self.voucher.is_active(START_DATETIME))

    def test_is_inactive_outside_of_start_and_end_dates(self):
        test = datetime.datetime(2012, 3, 10).replace(tzinfo=utc)
        self.assertFalse(self.voucher.is_active(test))

    def test_increments_total_discount_when_recording_usage(self):
        voucher = G(Voucher)
        voucher.record_discount({'discount': D('10.00')})
        self.assertEqual(voucher.total_discount, D('10.00'))
        voucher.record_discount({'discount': D('10.00')})
        self.assertEqual(voucher.total_discount, D('20.00'))
Beispiel #2
0
class TestAVoucher(TestCase):

    def setUp(self):
        self.voucher = Voucher(start_date=START_DATE, end_date=END_DATE)

    def test_is_active_between_start_and_end_dates(self):
        test = datetime.date(2011, 6, 10)
        self.assertTrue(self.voucher.is_active(test))

    def test_is_active_on_end_date(self):
        self.assertTrue(self.voucher.is_active(END_DATE))

    def test_is_active_on_start_date(self):
        self.assertTrue(self.voucher.is_active(START_DATE))

    def test_is_inactive_outside_of_start_and_end_dates(self):
        test = datetime.date(2012, 3, 10)
        self.assertFalse(self.voucher.is_active(test))

    def test_increments_total_discount_when_recording_usage(self):
        voucher = G(Voucher)
        voucher.record_discount({'discount': D('10.00')})
        self.assertEqual(voucher.total_discount, D('10.00'))
        voucher.record_discount({'discount': D('10.00')})
        self.assertEqual(voucher.total_discount, D('20.00'))
Beispiel #3
0
 def test_codes_are_saved_as_uppercase(self):
     start = datetime.date(2011, 01, 01)
     end = datetime.date(2011, 02, 01)
     voucher = Voucher(name="Dummy voucher",
                       code="lowercase",
                       start_date=start,
                       end_date=end)
     voucher.save()
     self.assertEquals("LOWERCASE", voucher.code)
Beispiel #4
0
 def setUp(self):
     self.voucher = Voucher(start_datetime=START_DATETIME,
                            end_datetime=END_DATETIME)
Beispiel #5
0
 def test_saves_code_as_uppercase(self):
     voucher = Voucher(code='lower',
                       start_datetime=START_DATETIME,
                       end_datetime=END_DATETIME)
     voucher.save()
     self.assertEqual('LOWER', voucher.code)
Beispiel #6
0
 def setUp(self):
     self.voucher = Voucher(start_date=START_DATE, end_date=END_DATE)
Beispiel #7
0
 def test_saves_code_as_uppercase(self):
     voucher = Voucher(code='lower', start_date=START_DATE,
                       end_date=END_DATE)
     voucher.save()
     self.assertEqual('LOWER', voucher.code)
Beispiel #8
0
 def test_is_active(self):
     start = datetime.date(2011, 01, 01)
     test = datetime.date(2011, 01, 10)
     end = datetime.date(2011, 02, 01)
     voucher = Voucher(start_date=start, end_date=end)
     self.assertTrue(voucher.is_active(test))
Beispiel #9
0
 def test_codes_are_saved_as_uppercase(self):
     start = datetime.date(2011, 01, 01)
     end = datetime.date(2011, 02, 01)
     voucher = Voucher(name="Dummy voucher", code="lowercase", start_date=start, end_date=end)
     voucher.save()
     self.assertEquals("LOWERCASE", voucher.code)
Beispiel #10
0
 def test_is_inactive_outside_of_start_and_end_dates(self):
     start = datetime.date(2011, 01, 01)
     test = datetime.date(2011, 03, 10)
     end = datetime.date(2011, 02, 01)
     voucher = Voucher(start_date=start, end_date=end)
     self.assertFalse(voucher.is_active(test))
Beispiel #11
0
 def test_is_active(self):
     start = datetime.date(2011, 01, 01)
     test = datetime.date(2011, 01, 10)
     end = datetime.date(2011, 02, 01)
     voucher = Voucher(start_date=start, end_date=end)
     self.assertTrue(voucher.is_active(test))