-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
300b25f
commit 47f84b3
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,24 +6,33 @@ | |
|
||
from ipr.models import IPR | ||
from tasks.models import Task | ||
from users.models import Team | ||
|
||
User = get_user_model() | ||
|
||
|
||
class TaskAPITests(APITestCase): | ||
def setUp(self): | ||
self.user0 = User.objects.create_user( | ||
username="user0", | ||
email="[email protected]", | ||
password="password", | ||
) | ||
self.team1 = Team.objects.create(name="Team 1", boss=self.user0) | ||
self.user1 = User.objects.create_user( | ||
username="user1", | ||
email="[email protected]", | ||
password="password", | ||
) | ||
self.team2 = Team.objects.create(name="Team 1", boss=self.user1) | ||
self.user2 = User.objects.create_user( | ||
username="user2", | ||
email="[email protected]", | ||
password="password", | ||
team=self.team2, | ||
) | ||
self.client = APIClient() | ||
self.client.force_authenticate(user=self.user2) | ||
self.client.force_authenticate(user=self.user1) | ||
self.ipr = IPR.objects.create( | ||
title="Test IPR", | ||
creation_date=timezone.now().date(), | ||
|
@@ -83,6 +92,26 @@ def test_create_task(self): | |
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
self.assertEqual(Task.objects.count(), 3) | ||
|
||
def test_create_task_for_other_user(self): | ||
""" | ||
Проверка создания новой задачи для пол-ля другой команды (POST) | ||
""" | ||
url = reverse("tasks-list") | ||
data = { | ||
"name": "New Task", | ||
"description": "New Description", | ||
"creator": self.user0.id, | ||
"creation_date": timezone.now().date(), | ||
"start_date": (timezone.now() + timezone.timedelta(days=1)).date(), | ||
"end_date": (timezone.now() + timezone.timedelta(days=2)).date(), | ||
"executor": self.user2.id, | ||
"ipr": self.ipr.id, | ||
} | ||
response = self.client.post(url, data, format="json") | ||
|
||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
self.assertEqual(Task.objects.count(), 3) | ||
|
||
def test_update_task(self): | ||
""" | ||
Проверка обновления задачи (PATCH) | ||
|
This file contains 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