Skip to content

Commit

Permalink
testcode_token_rename
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonju977 committed Sep 20, 2024
1 parent 1f7303c commit 7af2bda
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
23 changes: 14 additions & 9 deletions api/articles/tests/test_article_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 테스트 태그 생성
self.tag1 = Tag.objects.create(tag_id=2, name="연애 훈수")
Expand Down Expand Up @@ -143,8 +143,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 테스트 태그 생성
self.tag1 = Tag.objects.create(tag_id=0, name="연애 훈수")
Expand All @@ -168,9 +168,14 @@ def test_list_all_articles(self):
# 전체 게시글 조회 테스트
response = self.client.get(list_url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data), 2)
self.assertEqual(response.data[1]["title"], "Article 1")
self.assertEqual(response.data[0]["title"], "Article 2")

# 페이지네이션이 적용된 경우, 'results'에 게시글 리스트가 있음
article_list = response.data.get("results", [])

# 게시글의 개수가 2개인지 확인
self.assertEqual(len(article_list), 2)
self.assertEqual(article_list[1]["title"], "Article 1")
self.assertEqual(article_list[0]["title"], "Article 2")

def tearDown(self):
self.user.delete()
Expand Down Expand Up @@ -198,8 +203,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 테스트 태그 생성
self.tag1 = Tag.objects.create(tag_id=0, name="연애 훈수")
Expand Down
8 changes: 4 additions & 4 deletions api/profiles/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 어드민 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 테스트할 URL (조정당하는 일반 유저의 ID 사용)
self.url = f"/api/account/level/{self.user.id}/"
Expand Down Expand Up @@ -121,8 +121,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 테스트할 URL
self.url = "/api/account/profile/"
Expand Down
4 changes: 2 additions & 2 deletions api/reports/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def setUp(self):
self.refresh_token = str(self.refresh)

# 쿠키에 토큰 설정
self.client.cookies["access"] = self.access_token
self.client.cookies["refresh"] = self.refresh_token
self.client.cookies["hunsu_access"] = self.access_token
self.client.cookies["hunsu_refresh"] = self.refresh_token

# 신고당할 게시글 작성자 생성
self.reported_user = User.objects.create_user(
Expand Down

0 comments on commit 7af2bda

Please sign in to comment.