This commit is contained in:
Виктор Гладких 2019-10-09 16:44:29 +03:00
parent 77839c7e8c
commit 01dd728323
2 changed files with 19 additions and 17 deletions

View File

@ -20,14 +20,6 @@ class CommentModeratorPermissionTests(APITestCase):
)
self.country_ru.save()
self.country_en = Country.objects.create(
name='{"en-GB":"England"}',
code='25',
low_price=15,
high_price=150000
)
self.country_en.save()
self.role = Role.objects.create(
role=2,
country=self.country_ru
@ -53,15 +45,13 @@ class CommentModeratorPermissionTests(APITestCase):
content_type_id=content_type.id
)
self.comment.save()
self.url = reverse('back:comment:comment-crud', kwargs={"id": self.comment.id})
def test_get(self):
url = reverse('back:comment:comment-crud', kwargs={"id": 1})
response = self.client.get(url, format='json')
response = self.client.get(self.url, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_put_moderator(self):
url = reverse('back:comment:comment-crud', kwargs={"id": self.comment.id})
tokens = User.create_jwt_tokens(self.moderator)
self.client.cookies = SimpleCookie(
{'access_token': tokens.get('access_token'),
@ -74,11 +64,10 @@ class CommentModeratorPermissionTests(APITestCase):
"user": self.moderator.id
}
response = self.client.put(url, data=data, format='json')
response = self.client.put(self.url, data=data, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_put_other_user(self):
url = reverse('back:comment:comment-crud', kwargs={"id": self.comment.id})
other_user = User.objects.create_user(username='test',
email='test@mail.com',
password='passwordtest')
@ -96,11 +85,10 @@ class CommentModeratorPermissionTests(APITestCase):
"user": other_user.id
}
response = self.client.put(url, data=data, format='json')
response = self.client.put(self.url, data=data, format='json')
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_put_super_user(self):
url = reverse('back:comment:comment-crud', kwargs={"id": self.comment.id})
super_user = User.objects.create_user(username='super',
email='super@mail.com',
password='passwordtestsuper',
@ -119,7 +107,7 @@ class CommentModeratorPermissionTests(APITestCase):
"user": super_user.id
}
response = self.client.put(url, data=data, format='json')
response = self.client.put(self.url, data=data, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)

View File

@ -0,0 +1,14 @@
# Generated by Django 2.2.4 on 2019-10-09 13:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('timetable', '0003_auto_20191004_0928'),
('timetable', '0003_auto_20191003_0943'),
]
operations = [
]