티스토리 뷰
반응형
def test_report_create(self):
print("test_report_create")
response = self.client.post(self.url, data={'title': 'hi', 'content': 'hello'},
**{'HTTP_AUTHORIZATION': self.access_token_1})
self.assertEqual(response.status_code, 200)
위와 같이 **을 붙여서 표현 하는데 이 때 'HTTP_'을 붙여서 표현하는 것이 중요하다.
참고글: https://ssamko.tistory.com/53
[Django] Test 코드 작성시 header 추가하기
Django를 API서버로만 이용할 때, 외부 사용자들에게 header를 통해 인증정보를 받아야 할 경우가 있다. 이때, Test코드에서도 이를 처리해야 하는데, TestCase의 client에서 요청을 보낼때, from django.urls im
ssamko.tistory.com
반응형
'파이썬 > 장고' 카테고리의 다른 글
Object does not support item assignment error (0) | 2021.07.27 |
---|---|
Docker-compose를 통한 Django + Nginx + Postgres 작업 [.dockerignore] [docker-compose 환경변수/env 파일 처리하기] (0) | 2021.07.21 |
django testcase user create (0) | 2021.07.09 |
DRF Testcase headers 처리 (0) | 2021.07.09 |
django test response body 가져오기 (0) | 2021.07.09 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 카카오
- 그래프
- 파이썬
- ubuntu
- Linux
- Command Line
- PostgreSQL
- setattr
- 자바
- 알고리즘
- docker
- DRF
- Collections
- postgres
- headers
- Python
- 프로그래머스
- django
- thread
- 면접
- Pattern
- dockerignore
- 2021 KAKAO BLIND RECRUITMENT
- 백준
- Celery
- env
- docker-compose
- Java
- BFS
- Spring
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함