Example #1
0
    def test_signin_limit(self):
        self.plan1.signin_limit = 2
        user = Membership(first_name="Testy",
                          last_name="Testerson",
                          email="*****@*****.**",
                          plan="plan1")
        user.put()

        # We should have all 2 signins left.
        self.assertEqual(2, Plan.signins_remaining(user))

        # Signin once.
        user.signins = 1
        user.put()
        self.assertEqual(1, Plan.signins_remaining(user))

        # Signin again.
        user.signins = 2
        user.put()
        self.assertEqual(0, Plan.signins_remaining(user))

        # Should never be less than zero.
        user.signins = 3
        user.put()
        self.assertEqual(0, Plan.signins_remaining(user))

        # Give ourselves unlimited signins!
        self.plan1.signin_limit = None
        self.assertEqual(None, Plan.signins_remaining(user))
Example #2
0
  def test_signin_limit(self):
    self.plan1.signin_limit = 2
    user = Membership(first_name="Testy", last_name="Testerson",
                      email="*****@*****.**", plan="plan1")
    user.put()

    # We should have all 2 signins left.
    self.assertEqual(2, Plan.signins_remaining(user))

    # Signin once.
    user.signins = 1
    user.put()
    self.assertEqual(1, Plan.signins_remaining(user))

    # Signin again.
    user.signins = 2
    user.put()
    self.assertEqual(0, Plan.signins_remaining(user))

    # Should never be less than zero.
    user.signins = 3
    user.put()
    self.assertEqual(0, Plan.signins_remaining(user))

    # Give ourselves unlimited signins!
    self.plan1.signin_limit = None
    self.assertEqual(None, Plan.signins_remaining(user))
Example #3
0
  def test_rollover(self):
    self.user.signins = Config().LITE_VISITS - 2
    self.user.status = "active"
    self.user.put()

    response = self.test_app.get("/cron/reset_signins")
    self.assertEqual(200, response.status_int)

    user = Membership.get_by_email("*****@*****.**")
    self.assertEqual(-2, user.signins)
    self.assertEqual("active", user.status)

    # Test that signins_remaining gives us the right number.
    test_plan = Plan("test_lite", 1, 100, "A test plan",
                     signin_limit = Config().LITE_VISITS)
    user.plan = "test_lite"
    remaining = Plan.signins_remaining(user)
    self.assertEqual(Config().LITE_VISITS + 2, remaining)
Example #4
0
    def test_rollover(self):
        self.user.signins = Config().LITE_VISITS - 2
        self.user.status = "active"
        self.user.put()

        response = self.test_app.get("/cron/reset_signins")
        self.assertEqual(200, response.status_int)

        user = Membership.get_by_email("*****@*****.**")
        self.assertEqual(-2, user.signins)
        self.assertEqual("active", user.status)

        # Test that signins_remaining gives us the right number.
        test_plan = Plan("test_lite",
                         1,
                         100,
                         "A test plan",
                         signin_limit=Config().LITE_VISITS)
        user.plan = "test_lite"
        remaining = Plan.signins_remaining(user)
        self.assertEqual(Config().LITE_VISITS + 2, remaining)