Open
Conversation
Comment on lines
+55
to
+57
| comment_list = [{"author": comment.author, "text": comment.text} for comment in comments] | ||
|
|
||
| return JsonResponse({"data": comment_list}) |
Contributor
There was a problem hiding this comment.
nipick,
Suggested change
| comment_list = [{"author": comment.author, "text": comment.text} for comment in comments] | |
| return JsonResponse({"data": comment_list}) | |
| return JsonResponse({"data": [{"author": comment.author, "text": comment.text} for comment in comments]}) |
변수 선언안해줘도 코드로 인지 가능해서 인라인해서 써줘도 될거 같애~
| self.assertEqual(response["message"], "유효하지 않은 사용자 id입니다.") | ||
|
|
||
|
|
||
| class TestCommentList(TestPostMixin, TestCase): |
Comment on lines
+258
to
+260
| for i in range(comment_count): | ||
| comment = self._create_comment_on_post(self.post, f"author{i}", f"comment{i}") | ||
| comment.approve() |
Contributor
There was a problem hiding this comment.
이 부분은 extract method 할 수 있을 것 같애
* 다른 테스트들과 연관된 부분이 아니라서 굳이 뺄 필욘 없지만, 가독성 측면 혹은 나중에 혹시 재활용할 측면에서는 뺴는게 좋다고 생각함
...
def _create_comments_with_approve(self, comment_count):
for i in range(comment_count):
comment = self._create_comment_on_post(self.post, f"author{i}", f"comment{i}")
comment.approve()
...| ) | ||
|
|
||
|
|
||
| class CommentListCreate(View): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
comment list
url
GET /posts/{post_id}설명
결과
성공 (200)
{ "data": [ { "author": "test author", "text": "test text" }, {...}, ... ] }실패 (404)
post_id가 유효하지 않을 때{ "message": "post가 없습니다." }테스트
post_id입력post_id입력comment create
input
POST /posts/{post_id}{ "author": "test author", "text": "test text" }설명
post id와author, text를 json으로 입력받아 comment 생성결과
성공 (201)
comment가 생성된 post의 id와 comment 정보 return
{ "post_id": 123, "author": "test author", "text": "test text" }실패
post_id가 유효하지 않을 때 (404){ "message": "post가 없습니다." }author가 공백일 때 (400){ "message": "author가 없습니다." }text가 공백일 때 (400){ "message": "text가 없습니다." }테스트
post_id입력post_id입력author를 미입력text를 미입력