def test_request_viewset_actions():
class TheCase(APITestCase, TestCase):
view_class = APIViewSetTestView
viewset_actions = {'get': 'list'}
user = User(username='user')
case = TheCase()
response = case.request(user=user)
assert case._request.user == user
assert case._request.method == 'GET'
assert response.status_code == 200
assert isinstance(response.content, dict)
assert response.content == {"some": "json"}
assert response.location is None
assert 'content-type' in response.headers
assert response.headers['content-type'][1] == 'application/json'
assert len(response.messages) == 0
评论列表
文章目录