Ejemplo n.º 1
0
 def test_outbound_with_data(self, response, session):
     response.request.session['Hello'] = "Chad"
     outbound(response)
     assert len(Session.objects()) == 1
     assert pickle.loads(Session.objects(session_key="a" * 64)[0].data) == {
         'session_key': 'a' * 64,
         'Hello': "Chad"
         }
Ejemplo n.º 2
0
    def test_inbound_loads_data(self, request, session):
        session.data = pickle.dumps({"hello": 5})
        session.save()
        request.cookie['session_key'] = "a" * 64
        inbound(request)

        assert len(Session.objects()) == 1
        assert request.session['session_key'] == "a" * 64
        assert request.session['hello'] == 5
Ejemplo n.º 3
0
 def test_inbound_no_key(self, request):
     inbound(request)
     assert request.session.keys() == ["session_key"]
     assert len(Session.objects()) == 1
     assert Session.objects()[0]['session_key'] == request.session['session_key']
Ejemplo n.º 4
0
 def test_inbound_key_session(self, request, session):
     request.cookie['session_key'] = "a" * 64
     assert len(Session.objects()) == 1
     inbound(request)
     assert len(Session.objects()) == 1
     assert request.session['session_key'] == "a" * 64
Ejemplo n.º 5
0
def test_create_new_session_key(mongodb):
    t = Session.create_new_session()
    assert len(t.session_key) == 64