django.test.RequestFactory.get

Here are the examples of the python api django.test.RequestFactory.get taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: django-synctool
Source File: tests.py
View license
    def test_single(self):
        blog = Blog.objects.create(slug="blog")

        request = RequestFactory().get("/")
        request.META["HTTP_AUTHORIZATION"] = authorization()

        response = blog_single(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            response._headers["content-type"][1],
            "application/json",
        )

        data = deserialize("json", response.content)
        self.assertEqual(next(data).object, blog)

Example 2

Project: django-synctool
Source File: tests.py
View license
    def test_multiple(self):
        blog = Blog.objects.create(slug="blog")
        post = Post.objects.create(blog=blog, slug="slug")

        request = RequestFactory().get("/")
        request.META["HTTP_AUTHORIZATION"] = authorization()

        response = blog_multiple(request)

        self.assertEqual(response.status_code, 200)

        data = deserialize("json", response.content)

        self.assertEqual(next(data).object, blog)
        self.assertEqual(next(data).object, post)

Example 3

Project: django-synctool
Source File: tests.py
View license
    def test_app(self):
        blog = Blog.objects.create(slug="blog")
        post = Post.objects.create(blog=blog, slug="slug")

        request = RequestFactory().get("/")
        request.META["HTTP_AUTHORIZATION"] = authorization()

        response = blog_app(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            response._headers["content-type"][1],
            "application/json",
        )

        data = deserialize("json", response.content)

        self.assertEqual(next(data).object, blog)
        self.assertEqual(next(data).object, post)

Example 4

Project: django-synctool
Source File: tests.py
View license
    def test_bad_authorization(self):
        request = RequestFactory().get("/")
        request.META["HTTP_AUTHORIZATION"] = authorization(token="bad")

        response = self.client.get("/blog-single/")
        self.assertEqual(response.status_code, 401)

Example 5

Project: PyClassLessons
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_SECURE=True)
    def test_secure_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['secure'])

Example 6

Project: PyClassLessons
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=True)
    def test_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
        self.assertIn(http_cookies.Morsel._reserved['httponly'],
            str(response.cookies[settings.SESSION_COOKIE_NAME]))

Example 7

Project: PyClassLessons
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=False)
    def test_no_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])

        self.assertNotIn(http_cookies.Morsel._reserved['httponly'],
                         str(response.cookies[settings.SESSION_COOKIE_NAME]))

Example 8

Project: PyClassLessons
Source File: tests.py
View license
    def test_session_save_on_500(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Horrible error')
        response.status_code = 500
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)

        # Check that the value wasn't saved above.
        self.assertNotIn('hello', request.session.load())

Example 9

Project: django-test-plus
Source File: test.py
View license
    def get(self, cls, *args, **kwargs):
        """
        Calls cls.get() method after instantiating view class
        with `initkwargs`.
        Renders view templates and sets context if appropriate.
        """
        initkwargs = kwargs.pop('initkwargs', None)
        if initkwargs is None:
            initkwargs = {}
        request = RequestFactory().get('/')
        instance = self.get_instance(cls, initkwargs=initkwargs, request=request, **kwargs)
        self.last_response = self.get_response(request, instance.get)
        self.context = self.last_response.context
        return self.last_response

Example 10

Project: oioioi
Source File: controllers.py
View license
    def _fake_request(self, page):
        """Creates a fake request used to render ranking.

           Pagination engine requires access to request object, so it can
           extract page number from GET parameters.
        """
        fake_req = RequestFactory().get('/?page=' + str(page))
        fake_req.user = AnonymousUser()
        fake_req.contest = self.contest
        # This is required by django-linaro-pagination
        # Normally they monkey patch this function in their middleware
        fake_req.page = lambda _: page
        return fake_req

Example 11

Project: splunk-webframework
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_SECURE=True)
    def test_secure_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['secure'])

Example 12

Project: splunk-webframework
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=True)
    def test_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
        self.assertIn('httponly',
            str(response.cookies[settings.SESSION_COOKIE_NAME]))

Example 13

Project: splunk-webframework
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=False)
    def test_no_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])

        self.assertNotIn('httponly',
                         str(response.cookies[settings.SESSION_COOKIE_NAME]))

Example 14

Project: splunk-webframework
Source File: tests.py
View license
    def test_session_save_on_500(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Horrible error')
        response.status_code = 500
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)

        # Check that the value wasn't saved above.
        self.assertNotIn('hello', request.session.load())

Example 15

View license
    def setUp(self):
        super(TestTwoColumnLayoutBlock, self).setUp()
        self.user = factories.UserFactory.build()

        self.request = RequestFactory().get('/')
        self.request_context = RequestContext(self.request, {})
        self.request_context['user'] = self.user

Example 16

Project: django-fancypages
Source File: test_container.py
View license
@pytest.fixture
def request_context():
    request = RequestFactory().get('/')
    request.fp_edit_mode = True
    request.user = User()
    return RequestContext(request, {})

Example 17

Project: django-downloadview
Source File: tests.py
View license
    def test_get_path(self):
        """DynamicStorageDownloadView.get_path() returns uppercase path.

        Uses :func:`~django_downloadview.test.setup_view` to target only
        overriden methods.

        This test does not involve URLconf, middlewares or decorators. It is
        fast. It has clear scope. It does not assert ``storage:dynamic_path``
        URL works. It targets only custom ``DynamicStorageDownloadView`` class.

        """
        view = setup_view(views.DynamicStorageDownloadView(),
                          django.test.RequestFactory().get('/fake-url'),
                          path='dummy path')
        path = view.get_path()
        self.assertEqual(path, 'DUMMY PATH')

Example 18

Project: django-downloadview
Source File: sendfile.py
View license
    def test_defaults(self):
        """sendfile() takes at least request and filename."""
        request = django.test.RequestFactory().get('/fake-url')
        filename = __file__
        response = sendfile(request, filename)
        self.assertTrue(isinstance(response, DownloadResponse))
        self.assertFalse(response.attachment)

Example 19

Project: django-downloadview
Source File: views.py
View license
    def test_render_to_response_modified(self):
        """DownloadMixin.render_to_response() calls download_response()."""
        # Setup.
        mixin = views.DownloadMixin()
        mixin.request = django.test.RequestFactory().get(
            '/dummy-url',
            HTTP_IF_MODIFIED_SINCE=None)
        mixin.was_modified_since = mock.Mock()
        mixin.download_response = mock.Mock(
            return_value=mock.sentinel.download_response)
        mixin.get_file = mock.Mock(return_value=mock.sentinel.file_wrapper)
        # Run.
        response = mixin.render_to_response()
        # Check.
        self.assertIs(response, mock.sentinel.download_response)
        mixin.get_file.assert_called_once_with()
        self.assertEqual(mixin.was_modified_since.call_count, 0)
        mixin.download_response.assert_called_once_with()

Example 20

Project: django-downloadview
Source File: views.py
View license
    def test_render_to_response_file_not_found(self):
        "DownloadMixin.render_to_response() calls file_not_found_response()."
        # Setup.
        mixin = views.DownloadMixin()
        mixin.request = django.test.RequestFactory().get('/dummy-url')
        mixin.get_file = mock.Mock(side_effect=exceptions.FileNotFound)
        mixin.file_not_found_response = mock.Mock()
        # Run.
        mixin.render_to_response()
        # Check.
        mixin.file_not_found_response.assert_called_once_with()

Example 21

Project: django-downloadview
Source File: views.py
View license
    def test_get(self):
        """BaseDownloadView.get() calls render_to_response()."""
        request = django.test.RequestFactory().get('/dummy-url')
        args = ['dummy-arg']
        kwargs = {'dummy': 'kwarg'}
        view = setup_view(views.BaseDownloadView(), request, *args, **kwargs)
        view.render_to_response = mock.Mock(
            return_value=mock.sentinel.response)
        response = view.get(request, *args, **kwargs)
        self.assertIs(response, mock.sentinel.response)
        view.render_to_response.assert_called_once_with()

Example 22

Project: tri.table
Source File: test_tri_table.py
View license
def test_ajax_data_endpoint():

    class TestTable(Table):
        class Meta:
            endpoint__data = lambda table, key, value: [{cell.bound_column.name: cell.value for cell in row} for row in table]

        foo = Column()
        bar = Column()

    table = TestTable(data=[
        Struct(foo=1, bar=2),
        Struct(foo=3, bar=4),
    ])

    result = render_table(request=RequestFactory().get("/", {'__data': ''}), table=table)
    assert json.loads(result.content.decode('utf8')) == [dict(foo=1, bar=2), dict(foo=3, bar=4)]

Example 23

Project: tri.table
Source File: test_tri_table.py
View license
def test_ajax_endpoint_namespacing():
    class TestTable(Table):
        class Meta:
            endpoint_dispatch_prefix = 'foo'
            endpoint__bar = lambda **_: 17

        baz = Column()

    result = render_table(request=RequestFactory().get("/", {'__not_foo__bar': ''}), table=TestTable(data=[]))
    assert result is None
    result = render_table(request=RequestFactory().get("/", {'__foo__bar': ''}), table=TestTable(data=[]))
    assert 17 == json.loads(result.content.decode('utf8'))

Example 24

Project: tri.table
Source File: test_tri_table.py
View license
def test_table_iteration():

    class TestTable(Table):
        class Meta:
            data = [
                Struct(foo='a', bar=1),
                Struct(foo='b', bar=2)
            ]

        foo = Column()
        bar = Column(cell__value=lambda row, **_: row['bar'] + 1)

    table = TestTable(request=RequestFactory().get('/'))

    expected = [
        dict(foo='a', bar=2),
        dict(foo='b', bar=3),
    ]
    assert expected == [{bound_cell.bound_column.name: bound_cell.value for bound_cell in bound_row} for bound_row in table]

Example 25

Project: tri.table
Source File: test_tri_table.py
View license
def test_ajax_custom_endpoint():
    class TestTable(Table):
        class Meta:
            endpoint__foo = lambda table, key, value: dict(baz=value)
        spam = Column()

    result = render_table(request=RequestFactory().get("/", {'__foo': 'bar'}), table=TestTable(data=[]))
    assert json.loads(result.content.decode('utf8')) == dict(baz='bar')

Example 26

Project: tri.table
Source File: test_tri_table.py
View license
def test_table_extra_namespace():
    class TestTable(Table):
        class Meta:
            extra__foo = 17

        foo = Column()

    assert 17 == TestTable(request=RequestFactory().get('/'), data=[]).extra.foo

Example 27

Project: django-advanced-reports
Source File: test_api.py
View license
    def test_viewrequestparameters(self):
        request = RequestFactory().get('/?a=1&a=2&a=3')
        params = ViewRequestParameters(request)
        self.assertEqual(params.get('nonexisting', 'fallback'), 'fallback')
        self.assertEqual(params.getlist('a'), ['1', '2', '3'])
        self.assertEqual(params.getlist('nonexisting'), [])
        self.assertEqual(params.getlist('nonexisting', ['default']), ['default'])
        self.assertEqual(repr(params),
                         "ViewRequestParameters(<QueryDict: {u'a': [u'1', u'2', u'3']}>, " +
                         "<QueryDict: {}>, {})")

Example 28

View license
    def test_request_user_is_added_to_the_result(self):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')
        request.user = mommy.make(get_user_model())

        res = ratings({
            'request': request,
        }, item)

        self.assertEqual(request.user, res['user'])

Example 29

View license
    def test_user_is_authenticated_without_rating_for_object___user_rating_is_none(self):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')

        request.user = get_user_model().objects.create_user(username='user', password='pass')
        self.client.login(username='user', password='pass')

        res = ratings({
            'request': request,
        }, item)

        self.assertIsNone(res['user_rating'])

Example 30

View license
    def test_user_is_not_authenticated_with_rating_for_object___user_rating_is_none(self):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')
        request.user = AnonymousUser()

        res = ratings({
            'request': request,
        }, item)

        self.assertIsNone(res['user_rating'])

Example 31

View license
    def test_stars_list_is_added_to_the_result(self):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')
        request.user = mommy.make(get_user_model())

        res = ratings({
            'request': request,
        }, item)

        self.assertEqual(list(range(1, app_settings.STAR_RATINGS_RANGE + 1)), res['stars'])

Example 32

View license
    def test_star_count_is_added_to_the_result(self):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')
        request.user = mommy.make(get_user_model())

        res = ratings({
            'request': request,
        }, item)

        self.assertEqual(app_settings.STAR_RATINGS_RANGE, res['star_count'])

Example 33

View license
    @given(scores=lists(scores()), settings=Settings(max_examples=5))
    def test_several_ratings_are_made___percentage_is_correct_in_result(self, scores):
        item = mommy.make(Foo)

        request = RequestFactory().get('/')
        request.user = mommy.make(get_user_model())

        for score in scores:
            Rating.objects.rate(item, score, mommy.make(get_user_model()))

        rating = Rating.objects.for_instance(item)

        res = ratings({
            'request': request,
        }, item)

        expected_avg = 100 * (rating.average / Decimal(app_settings.STAR_RATINGS_RANGE))
        self.assertEqual(expected_avg, res['percentage'])

Example 34

View license
    @classmethod
    def setUpClass(cls):
        for i in range(0, 3):
            Group.objects.create(name='ViewTestCase%s' % i)

        cls.request = test.RequestFactory().get('?q=foo')
        super(Select2QuerySetSequenceViewTestCase, cls).setUpClass()

Example 35

Project: OIPA
Source File: test_dynamic_serializer.py
View license
    def test_fields_serializer(self):
        request = RequestFactory().get('/')

        context = {
                'view': SimpleView,
                'request': request
                }
        serializer = SimpleModelSerializer(
                data=self.data,
                context=context,
                fields=('id','name')
                )
        serializer.is_valid()

        self.assertIn('id', serializer.data)
        self.assertIn('name', serializer.data)
        self.assertNotIn('description', serializer.data)

Example 36

View license
    def test_dispatch(self):
        req = RequestFactory().get('/', data={'skip_form': 1, })
        result = views.DummyFormView().dispatch(req)
        self.assertEqual(result._headers['location'][1], '/success/', msg=(
            'When `skip_form` is in data, dispatch should just redirect to the'
            ' success URL.'))

        result = views.DummyUpdateView().dispatch(req, pk=1)
        self.assertEqual(result._headers['location'][1], '/success/', msg=(
            'When `skip_form` is in data, dispatch should just redirect to the'
            ' success URL.'))

Example 37

View license
    def test_middleware(self):
        self.influxdb_client.delete_series(measurement='django_request')

        req = RequestFactory().get('/?campaign=bingo')
        req.META['HTTP_REFERER'] = 'http://google.co.uk/foobar/'
        req.user = AnonymousUser()
        mware = InfluxDBRequestMiddleware()
        mware.process_view(req, 'view_funx', 'view_args', 'view_kwargs')
        mware.process_exception(req, None)

        results = list(query('select * from django_request'))
        self.assertEqual(len(results), 1)
        result = results[0][0]
        self.assertEqual(result['value'], 0)

Example 38

Project: django-libs
Source File: libs_tags_tests.py
View license
    @patch('django_libs.templatetags.libs_tags.resolve')
    def test_use_resolver_true(self, mock_resolve):
        req = RequestFactory().get('/index/test/')
        tags.navactive(req, '/index/test/')
        self.assertTrue(mock_resolve.called, msg=(
            'When calling the tag normally, we will try to resolve the given'
            ' url.'))

Example 39

Project: django-libs
Source File: libs_tags_tests.py
View license
    @patch('django_libs.templatetags.libs_tags.resolve')
    def test_use_resolver_false(self, mock_resolve):
        req = RequestFactory().get('/index/test/')
        tags.navactive(req, '/index/test/', use_resolver=False)
        self.assertFalse(mock_resolve.called, msg=(
            'When calling the tag with use_resolve=False the resolver should'
            ' not be called at all'))

Example 40

Project: django-online-docs
Source File: views_tests.py
View license
    def test_get_document_name(self):
        req = RequestFactory().get(self.get_url() + '?path=/docs/')
        view = OnlineDocsView()
        view.dispatch(req)
        result = view.get_document_name()
        self.assertEqual(result, 'online_docs_view.md', msg=(
            'Should resolve the given path and return the filename with the'
            ' format "<namespace>.<view_name>.md", but returned %s' % result))

Example 41

Project: django-online-docs
Source File: views_tests.py
View license
    def test_get_template_names(self):
        req = RequestFactory().get(self.get_url() + '?path=/docs/')
        view = OnlineDocsView()
        view.dispatch(req)
        result = view.get_template_names()
        self.assertEqual(result, ['online_docs/online_docs.html'], msg=(
            'Should return the template of this app'))

        req.is_ajax = lambda: True
        view.dispatch(req)
        result = view.get_template_names()
        self.assertEqual(result, ['online_docs/partials/online_docs.html'],
            msg=('Should return the patial template if the request is an'
                 ' ajax call'))

Example 42

View license
    def get_req_and_view(self):
        self.login(self.user)
        req = RequestFactory().get('/', data=self.get_post_data())
        req.user = self.user
        view = DoExpressCheckoutView()
        return req, view

Example 43

Project: osf.io
Source File: test_views.py
View license
    def test_checkout_files(self):
        self.draft.submit_for_review(self.user, {}, save=True)
        request = RequestFactory().get('/fake_path')
        view = DraftDetailView()
        view = setup_user_view(view, request, self.admin_user,
                               draft_pk=self.draft._id)
        view.checkout_files(self.draft)
        for q, f in self.d_of_qs.iteritems():
            nt.assert_equal(self.prereg_user, f.checkout)

Example 44

Project: osf.io
Source File: test_views.py
View license
    def test_checkin_files(self):
        self.draft.submit_for_review(self.user, {}, save=True)
        request = RequestFactory().get('/fake_path')
        view = DraftDetailView()
        view = setup_user_view(view, request, self.admin_user,
                               draft_pk=self.draft._id)
        view.checkout_files(self.draft)
        view2 = DraftFormView()
        view2 = setup_view(view2, request, draft_pk=self.draft._id)
        view2.checkin_files(self.draft)
        for q, f in self.d_of_qs.iteritems():
            nt.assert_equal(None, f.checkout)

Example 45

Project: osf.io
Source File: test_views.py
View license
    def test_no_guid(self):
        request = RequestFactory().get('/fake_path')
        view = UserView()
        view = setup_view(view, request)
        with nt.assert_raises(AttributeError):
            view.get_object()

Example 46

Project: django-nonrel
Source File: tests.py
View license
    def test_secure_session_cookie(self):
        settings.SESSION_COOKIE_SECURE = True

        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(response.cookies[settings.SESSION_COOKIE_NAME]['secure'])

Example 47

Project: django-nonrel
Source File: tests.py
View license
    def test_httponly_session_cookie(self):
        settings.SESSION_COOKIE_HTTPONLY = True

        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])

Example 48

Project: hue
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_SECURE=True)
    def test_secure_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['secure'])

Example 49

Project: hue
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=True)
    def test_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertTrue(
            response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])
        self.assertIn('httponly',
            str(response.cookies[settings.SESSION_COOKIE_NAME]))

Example 50

Project: hue
Source File: tests.py
View license
    @override_settings(SESSION_COOKIE_HTTPONLY=False)
    def test_no_httponly_session_cookie(self):
        request = RequestFactory().get('/')
        response = HttpResponse('Session test')
        middleware = SessionMiddleware()

        # Simulate a request the modifies the session
        middleware.process_request(request)
        request.session['hello'] = 'world'

        # Handle the response through the middleware
        response = middleware.process_response(request, response)
        self.assertFalse(response.cookies[settings.SESSION_COOKIE_NAME]['httponly'])

        self.assertNotIn('httponly',
                         str(response.cookies[settings.SESSION_COOKIE_NAME]))