-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
サインアップ機能 #1
サインアップ機能 #1
Conversation
black(フォーマッタ)のチェックに失敗しました。CI実行のログを確認して修正し,再度コミット・プッシュしてください。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最終課題の最初のステップ、画面と機能が要件通り実装できていてよかったです👍
いくつか修正点がありますので、ご確認お願いします🙏
accounts/views.py
Outdated
|
||
def form_valid(self, form): | ||
response = super().form_valid(form) | ||
print(self.object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使っていないprint文は削除しておきましょう🗑️
tweets/views.py
Outdated
@@ -1 +1,7 @@ | |||
# from django.shortcuts import render |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使わなかったモジュールは消して大丈夫です!
accounts/tests.py
Outdated
form = response.context["form"] | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertFalse(User.objects.filter(email=invalid_data["username"]).exists()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
63行目のfilter
でemail
とusername
を比較しているため、意図したチェックになっていないかもしれません。
他にも同様の箇所があるので、このファイル全体を見直してみてください!
具体的には、username
フィールドがユニークなので、username
でフィルターするといいです!
詳しい説明は、Wikiのサインアップ機能のページのSTEP5の04.の3. postのテスト
のdef test_success_post(self)の詳しい説明
の3. self.assertTrue … の説明
にあります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前回の3つの修正点については問題なく対応されていて、OKでした!🙌
その上で、新たに修正点が見つかったので確認をお願いします🙏
accounts/tests.py
Outdated
self.assertEqual(response.status_code, 200) | ||
self.assertFalse(form.is_valid()) | ||
self.assertIn("同じユーザー名が既に登録済みです。", form.errors["username"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_failure_post_with_duplicated_user
メソッドで、期待する効果「DBにレコードが追加されていないこと」のチェックが抜けているようです。
self.assertFalse(form.is_valid()) | ||
self.assertIn("このフィールドは必須です。", form.errors["password1"]) | ||
self.assertIn("このフィールドは必須です。", form.errors["password2"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
【提案(必須じゃない)】
password2
に変えるなら、password1
でも同じformエラーが出てるので、どっちも書いちゃってもいいかもです!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertFalse(form.is_valid()) | ||
self.assertEqual(User.objects.filter(username=duplicated_data["username"]).count(), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
【提案(必須じゃない)】
やっていることは変わりませんが、valid_data["username"]
を使った方が意味的に自然かと思います。こんな感じで修正してみてはいかがでしょうか?
self.assertEqual(User.objects.filter(username=duplicated_data["username"]).count(), 1) | |
self.assertEqual(User.objects.filter(username=valid_data["username"]).count(), 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
受講生の確認事項
1次レビュアーの確認事項