Exemplo n.º 1
0
 def setUp(self):                        
     #create some generic stuff that is used by many of the tests
     self.bar = m.Bar(name=self.BAR['name'], password=self.BAR['password'], longitude=self.BAR['long'], latitude=self.BAR['lat'], address=self.BAR['address'])
     self.bar.save()
     self.coupon = m.Coupon(bar=self.bar, applies_to=None, coupon_type=self.COUPON['type'], alcohol_type=None, alcohol_specifics=None,
         original_price=self.COUPON['o_price'], discounted_price=self.COUPON['d_price'], num_issued=self.COUPON['num_issued'], num_remaining=self.COUPON['num_remaining'],
         issued_at=h.get_bar_now(self.bar.bar_tz), expires_at=h.get_bar_now(self.bar.bar_tz) + datetime.timedelta(days=1),
         effective_at=h.get_bar_now(self.bar.bar_tz))
     self.coupon.save()
     
     self.to_destroy = [self.bar, self.coupon]    #an array of models to destroy in the teardown
Exemplo n.º 2
0
    def test_get_queued(self):
        self.assertIn(self.coupon, q.get_queued(self.bar).all())

        # Test that the coupon is queued when its effective time is in the future 
        self.coupon.effective_at = h.get_bar_now(self.bar.bar_tz) + datetime.timedelta(minutes=5)
        self.coupon.save()
        self.assertIn(self.coupon, q.get_queued(self.bar).all())
    
        #test that the coupon is not queued when it should be expoired        
        self.coupon.expires_at = h.get_bar_now(self.bar.bar_tz) - datetime.timedelta(minutes=5)
        self.coupon.save()
        self.assertFalse(q.get_queued(self.bar).exists())
Exemplo n.º 3
0
 def test_get_active(self):
     self.assertIn(self.coupon, q.get_active(self.bar).all())
     
     # Test that the coupon is not active when it shouldnt be effective yet 
     self.coupon.effective_at = h.get_bar_now(self.bar.bar_tz) + datetime.timedelta(minutes=5)
     self.coupon.save()         
     self.assertFalse(q.get_active(self.bar).exists())        
     
     #reset effective at
     self.coupon.effective_at = h.get_bar_now(self.bar.bar_tz)
     self.coupon.save()
     
     #test that the coupon is not active when it should be expoired        
     self.coupon.expires_at = h.get_bar_now(self.bar.bar_tz) - datetime.timedelta(minutes=5)
     self.coupon.save()
     self.assertFalse(q.get_active(self.bar).exists())
Exemplo n.º 4
0
 def redeem_coupons(self, num):
     for i in range(0, num):
         coupon_redemption = m.CouponRedemption(touch_datetime=h.get_bar_now(self.bar.bar_tz), phone=None, coupon=self.coupon)
         coupon_redemption.save()
         self.to_destroy.append(coupon_redemption)