예제 #1
0
 def test_repr(self):
     s = SessionMixin()
     s.expiry_date = 10
     s.session_id = 42
     s.promoted = 1
     self.assertTrue(str(s.expiry_date) in repr(s))
     self.assertTrue(str(s.session_id) in repr(s))
     self.assertTrue(str(s.expiry_date) in repr(s))
예제 #2
0
 def test_repr(self):
     s = SessionMixin()
     s.expiry_date = 10
     s.session_id = 42
     s.promoted = 1
     self.assertTrue(str(s.expiry_date) in repr(s))
     self.assertTrue(str(s.session_id) in repr(s))
     self.assertTrue(str(s.expiry_date) in repr(s))
예제 #3
0
    def test_is_alive_correctly_handles_expiration(self):
        time = TimeMock(0)

        s = SessionMixin(expiry=42, time_module=time)
        self.assertTrue(s.is_alive())

        s = SessionMixin(expiry=42, time_module=time)
        time.set(43)
        self.assertFalse(s.is_alive())
예제 #4
0
    def test_is_alive_correctly_handles_expiration(self):
        time = TimeMock(0)

        s = SessionMixin(expiry=42, time_module=time)
        self.assertTrue(s.is_alive())

        s = SessionMixin(expiry=42, time_module=time)
        time.set(43)
        self.assertFalse(s.is_alive())
예제 #5
0
    def test_promote(self):
        time = TimeMock(42)

        s = SessionMixin(expiry=10, time_module=time)
        s.promote()
        self.assertEquals(s.expiry_date, 52)
예제 #6
0
 def test_repr_with_unpromoted_session(self):
     s = SessionMixin()
     s.promoted = None
     self.assertTrue('0' in repr(s))
예제 #7
0
 def session_factory(expiry):
     time = TimeMock(0)
     return SessionMixin(expiry=expiry, time_module=time)
예제 #8
0
    def test_promote(self):
        time = TimeMock(42)

        s = SessionMixin(expiry=10, time_module=time)
        s.promote()
        self.assertEquals(s.expiry_date, 52)
예제 #9
0
 def test_creation_with_expiry_arg_also_sets_expiry_date(self):
     s = SessionMixin(expiry=42)
     self.assertTrue(s.expiry_date is not None)
예제 #10
0
 def test_creation_with_no_sid_sets_a_random_one(self):
     s = SessionMixin()
     self.assertTrue(s.session_id is not None)
예제 #11
0
 def test_repr_with_unpromoted_session(self):
     s = SessionMixin()
     s.promoted = None
     self.assertTrue('0' in repr(s))
예제 #12
0
 def test_repr_with_no_expiry_date(self):
     s = SessionMixin()
     self.assertTrue('-1' in repr(s))