'Tests that if the X-Frame-Options header is already set then the
middleware does not attempt to override it.'

def test_dont_set_if_set(self):

    with override_settings(X_FRAME_OPTIONS=u'DENY'):
        response = HttpResponse()
        response[u'X-Frame-Options'] = u'SAMEORIGIN'
        r = XFrameOptionsMiddleware().process_response(HttpRequest(), response)
        self.assertEqual(r[u'X-Frame-Options'], u'SAMEORIGIN')
    with override_settings(X_FRAME_OPTIONS=u'SAMEORIGIN'):
        response = HttpResponse()
        response[u'X-Frame-Options'] = u'DENY'
        r = XFrameOptionsMiddleware().process_response(HttpRequest(), response)
        self.assertEqual(r[u'X-Frame-Options'], u'DENY')
