def test_request_get():
class TheCase(ViewTestCase, TestCase):
view_class = views.GenericView
request_meta = {'HTTP_REFERER': 'http://example.com'}
user = User(username='user')
case = TheCase()
response = case.request(user=user)
assert case._request.user == user
assert case._request.method == 'GET'
assert case._request.META['SERVER_NAME'] == 'testserver'
assert case._request.META['SERVER_PORT'] == '80'
assert case._request.META['HTTP_REFERER'] == 'http://example.com'
assert response.status_code == 200
assert response.content == '<h1>Test content<h1>'
assert response.location is None
assert 'content-type' in response.headers
assert len(response.messages) == 1
assert 'Hello world.' in response.messages
评论列表
文章目录