コード例 #1
0
    def test_serialize_unserialize(self):
        dt = datetime(2011, 7, 9, 13, 14, 15)
        id = 59034

        sid = SessionID(id, dt)
        data = sid.serialize()

        SessionID(123)

        restored_sid = sid.unserialize(data)

        self.assertEqual(sid.id, restored_sid.id)
        self.assertEqual(sid.created, restored_sid.created)
コード例 #2
0
    def test_automatic_created_date(self):
        start = datetime.utcnow()
        sid = SessionID(0)
        end = datetime.utcnow()

        self.assertTrue(start <= sid.created <= end)
コード例 #3
0
    def test_serialize(self):
        t = int(time.time())
        dt = datetime.utcfromtimestamp(t)
        sid = SessionID(1234, dt)

        self.assertEqual('%x_%x' % (1234, t), sid.serialize())