Add Signup Test - Update User/Poll data

This commit is contained in:
sosokker 2023-09-14 23:48:52 +07:00
parent 15d61b8c32
commit 0d42e56139
3 changed files with 51 additions and 25 deletions

View File

@ -4,7 +4,7 @@
"pk": 1,
"fields": {
"question_text": "Python vs C++, which one is better in your opinion?",
"pub_date": "2023-09-05T06:31:14Z",
"pub_date": "2023-09-11T06:31:14Z",
"end_date": "2023-09-29T20:31:49Z",
"short_description": "Cool kids have polls",
"long_description": "No description provide for this poll.",
@ -20,7 +20,7 @@
"fields": {
"question_text": "The chicken and the egg, which came first?",
"pub_date": "2023-09-11T02:50:04Z",
"end_date": "2023-09-19T23:50:19Z",
"end_date": "2023-10-18T23:50:19Z",
"short_description": "Cool kids have polls",
"long_description": "No description provide for this poll.",
"up_vote_count": 1,
@ -35,7 +35,7 @@
"fields": {
"question_text": "So far so good?",
"pub_date": "2023-08-03T06:50:43Z",
"end_date": "2023-11-15T19:50:53Z",
"end_date": "2023-11-28T19:50:53Z",
"short_description": "Cool kids have polls",
"long_description": "No description provide for this poll.",
"up_vote_count": 1,
@ -50,7 +50,7 @@
"fields": {
"question_text": "Do you love Django?",
"pub_date": "2023-09-11T19:51:12Z",
"end_date": "2023-09-13T17:51:18Z",
"end_date": "2023-09-29T17:51:18Z",
"short_description": "Cool kids have polls",
"long_description": "No description provide for this poll.",
"up_vote_count": 10,
@ -239,6 +239,15 @@
"question": 2
}
},
{
"model": "polls.vote",
"pk": 13,
"fields": {
"choice": 6,
"user": 6,
"question": 3
}
},
{
"model": "polls.sentimentvote",
"pk": 1,

View File

@ -4,7 +4,7 @@
"pk": 1,
"fields": {
"password": "pbkdf2_sha256$600000$aDh9a1PXxcXAb8z3YIjAPX$NVH24kt/wMad+0fZcCii738dfojI4vL2ffXOwNRuLz4=",
"last_login": "2023-09-14T11:36:53.463Z",
"last_login": "2023-09-14T16:45:03.576Z",
"is_superuser": true,
"username": "admin",
"first_name": "",
@ -76,7 +76,7 @@
"pk": 5,
"fields": {
"password": "pbkdf2_sha256$600000$aHyU2gjOR6Vfsh3DBMIvQy$PZwRu+rOLc+N15DDguvy29dks6GUiN5YN/4io8b390o=",
"last_login": null,
"last_login": "2023-09-14T14:49:50.765Z",
"is_superuser": false,
"username": "novote",
"first_name": "",
@ -92,27 +92,9 @@
{
"model": "auth.user",
"pk": 6,
"fields": {
"password": "",
"last_login": null,
"is_superuser": false,
"username": "",
"first_name": "",
"last_name": "",
"email": "",
"is_staff": false,
"is_active": true,
"date_joined": "2023-09-14T11:36:26.831Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 7,
"fields": {
"password": "pbkdf2_sha256$600000$5rNKsClojvcsBqzrEmAzy5$XpeAUCrzeLG42H+8o4HBVqifKd0cQuWcEhFax/dxS5M=",
"last_login": "2023-09-14T11:38:13.888Z",
"last_login": "2023-09-14T16:44:29.087Z",
"is_superuser": false,
"username": "tester4",
"first_name": "",

View File

@ -0,0 +1,35 @@
from django.contrib.auth.models import User
from django.test import TestCase
from django.urls import reverse
class SignUpTestCase(TestCase):
def test_signup_view(self):
"""Test Sign Up view Load correctly or not"""
signup_url = reverse("polls:signup")
response = self.client.get(signup_url)
self.assertEqual(response.status_code, 200)
def test_signup_success(self):
"""Test the signup System, is it work or not."""
signup_url = reverse('polls:signup')
data = {
'username': 'testuser',
'password1': 'testpassword123',
'password2': 'testpassword123',
}
response = self.client.post(signup_url, data)
self.assertEqual(response.status_code, 302)
self.assertTrue(User.objects.filter(username='testuser').exists())
def test_signup_validation_error(self):
"""Test for data validation of Sign Up form"""
signup_url = reverse('polls:signup')
data = {
'username': '',
'password1': 'testpassword123',
'password2': 'testpassword123',
}
response = self.client.post(signup_url, data)
self.assertEqual(response.status_code, 200)
self.assertFalse(User.objects.filter(username='').exists())