def test_should_associate_logged_user_to_a_existing_usersession(
        mocked_request, logged_user):
    request = get_or_create_session(mocked_request)
    request.user = logged_user
    get_or_create_session(request)

    assert UserSession.objects.get().user == logged_user
def request_created_in_fixture(mocked_request):
    return get_or_create_session(mocked_request)
def test_should_create_only_one_usersession_per_session(mocked_request):
    request1 = get_or_create_session(mocked_request)
    request2 = get_or_create_session(mocked_request)
    assert request1.session['analytics'] == request2.session['analytics']
def request_created_in_fixture_with_logged_user(mocked_request_logged):
    return get_or_create_session(mocked_request_logged)
 def __call__(self, request):
     request = get_or_create_session(request)
     create_pageview(request)
     return self.get_response(request)