Ejemplo n.º 1
0
 def test_use_reuse(self):
     time = datetime.timedelta(days=30, hours=11)
     gc = GiftCode(time=time)
     gc.use(self.u)
     self.assertEqual(self.u.paid_time_left.days, time.days)
     self.assertRaises(models.AlreadyUsedGiftCode, gc.use, self.u)
     self.assertEqual(self.u.paid_time_left.days, time.days)
     gc.use(self.u, reuse=True)
     self.assertTrue(self.u.is_paid)
     self.assertEqual(self.u.paid_time_left.days, time.days * 2)
Ejemplo n.º 2
0
    def setUp(self):
        super().setUp()

        self.testuser = User(username='******', password='******')
        self.session.add(self.testuser)
        self.testadmin = User(username='******', password='******')
        self.testadmin.is_admin = True
        self.session.add(self.testadmin)
        self.session.flush()
        self.testcode = GiftCode(datetime.timedelta(days=7))
        self.session.add(self.testcode)
        self.session.flush()
Ejemplo n.º 3
0
    def setUp(self):
        settings = {'mako.directories': 'ccvpn:templates/'}
        self.config = testing.setUp(settings=settings)
        setup_routes(self.config)
        self.session = setup_database()

        self.testuser = User(username='******', password='******')
        self.session.add(self.testuser)
        self.testadmin = User(username='******', password='******')
        self.testadmin.is_admin = True
        self.session.add(self.testadmin)
        self.session.flush()
        self.testcode = GiftCode(datetime.timedelta(days=7))
        self.session.add(self.testcode)
        self.session.flush()
Ejemplo n.º 4
0
 def test_use_freeonly(self):
     gc = GiftCode()
     gc.free_only = True
     self.assertRaises(models.AlreadyUsedGiftCode, gc.use, self.pu)
     gc.use(self.u)
     self.assertTrue(self.u.is_paid)
Ejemplo n.º 5
0
 def test_username_if_used(self):
     gc = GiftCode()
     self.assertIs(gc.username_if_used, False)
     gc.used = self.u.id
     gc.user = self.u
     self.assertEqual(gc.username_if_used, self.u.username)