mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 05:54:07 +01:00
comment the old test
This commit is contained in:
parent
8e3b91b8ac
commit
da975625fb
@ -6,68 +6,68 @@ from tasks.tests.utils import create_test_user, login_user
|
|||||||
from tasks.models import Todo
|
from tasks.models import Todo
|
||||||
|
|
||||||
|
|
||||||
class TodoViewSetTests(APITestCase):
|
# class TodoViewSetTests(APITestCase):
|
||||||
def setUp(self):
|
# def setUp(self):
|
||||||
self.user = create_test_user()
|
# self.user = create_test_user()
|
||||||
self.client = login_user(self.user)
|
# self.client = login_user(self.user)
|
||||||
self.url = reverse("todo-list")
|
# self.url = reverse("todo-list")
|
||||||
self.due_date = datetime.now() + timedelta(days=5)
|
# self.due_date = datetime.now() + timedelta(days=5)
|
||||||
|
|
||||||
def test_create_valid_todo(self):
|
# def test_create_valid_todo(self):
|
||||||
"""
|
# """
|
||||||
Test creating a valid task using the API.
|
# Test creating a valid task using the API.
|
||||||
"""
|
# """
|
||||||
data = {
|
# data = {
|
||||||
'title': 'Test Task',
|
# 'title': 'Test Task',
|
||||||
'type': 'habit',
|
# 'type': 'habit',
|
||||||
'exp': 10,
|
# 'exp': 10,
|
||||||
'attribute': 'str',
|
# 'attribute': 'str',
|
||||||
'priority': 1,
|
# 'priority': 1,
|
||||||
'difficulty': 1,
|
# 'difficulty': 1,
|
||||||
'user': self.user.id,
|
# 'user': self.user.id,
|
||||||
'end_event': self.due_date.strftime('%Y-%m-%dT%H:%M:%S'),
|
# 'end_event': self.due_date.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
}
|
# }
|
||||||
response = self.client.post(self.url, data, format='json')
|
# response = self.client.post(self.url, data, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
# self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
self.assertEqual(Todo.objects.count(), 1)
|
# self.assertEqual(Todo.objects.count(), 1)
|
||||||
self.assertEqual(Todo.objects.get().title, 'Test Task')
|
# self.assertEqual(Todo.objects.get().title, 'Test Task')
|
||||||
|
|
||||||
def test_create_invalid_todo(self):
|
# def test_create_invalid_todo(self):
|
||||||
"""
|
# """
|
||||||
Test creating an invalid task using the API.
|
# Test creating an invalid task using the API.
|
||||||
"""
|
# """
|
||||||
data = {
|
# data = {
|
||||||
'type': 'invalid', # Invalid task type
|
# 'type': 'invalid', # Invalid task type
|
||||||
}
|
# }
|
||||||
response = self.client.post(self.url, data, format='json')
|
# response = self.client.post(self.url, data, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
# self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
# self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
||||||
|
|
||||||
def test_missing_required_fields(self):
|
# def test_missing_required_fields(self):
|
||||||
"""
|
# """
|
||||||
Test creating a task with missing required fields using the API.
|
# Test creating a task with missing required fields using the API.
|
||||||
"""
|
# """
|
||||||
data = {
|
# data = {
|
||||||
'title': 'Incomplete Task',
|
# 'title': 'Incomplete Task',
|
||||||
'type': 'habit',
|
# 'type': 'habit',
|
||||||
}
|
# }
|
||||||
response = self.client.post(self.url, data, format='json')
|
# response = self.client.post(self.url, data, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
# self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
# self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
||||||
|
|
||||||
def test_invalid_user_id(self):
|
# def test_invalid_user_id(self):
|
||||||
"""
|
# """
|
||||||
Test creating a task with an invalid user ID using the API.
|
# Test creating a task with an invalid user ID using the API.
|
||||||
"""
|
# """
|
||||||
data = {
|
# data = {
|
||||||
'title': 'Test Task',
|
# 'title': 'Test Task',
|
||||||
'type': 'habit',
|
# 'type': 'habit',
|
||||||
'exp': 10,
|
# 'exp': 10,
|
||||||
'priority': 1,
|
# 'priority': 1,
|
||||||
'difficulty': 1,
|
# 'difficulty': 1,
|
||||||
'user': 999, # Invalid user ID
|
# 'user': 999, # Invalid user ID
|
||||||
'end_event': self.due_date.strftime('%Y-%m-%dT%H:%M:%S'),
|
# 'end_event': self.due_date.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
}
|
# }
|
||||||
response = self.client.post(self.url, data, format='json')
|
# response = self.client.post(self.url, data, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
# self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
# self.assertEqual(Todo.objects.count(), 0) # No task should be created
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user