Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaMihailovna committed Aug 25, 2023
1 parent 63de3a6 commit db816b7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions backend/api/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
class RecipeBookAPITestCase(TestCase):
def setUp(self):
# self.guest_client = Client()
self.user = User.objects.create_user(email='admin')
self.user = User.objects.create_user(email="vpupkin@yandex.ru",
username="vasya.pupkin",
first_name="Вася",
last_name="Пупкин",
password="Qwerty123"
)
self.authorized_client = Client()
self.authorized_client.force_login(self.user)

Expand All @@ -20,11 +25,12 @@ def test_list_exists(self):

def test_recipe_creation(self):
"""Проверка создания рецепта."""
data = {"email": "vpupkin@yandex.ru",
"username": "vasya.pupkin",
"first_name": "Вася",
"last_name": "Пупкин",
"password": "Qwerty123"}
data = {"ingredients": [{}],
"tags": [],
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAgMAAABieywaAAAACVBMVEUAAAD///9fX1/S0ecCAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAACklEQVQImWNoAAAAggCByxOyYQAAAABJRU5ErkJggg==",
"name": "string",
"text": "string",
"cooking_time": 1}
response = self.authorized_client.post('/api/pecipe/', data=data)
self.assertEqual(response.status_code, HTTPStatus.CREATED)
self.assertTrue(
Expand Down

0 comments on commit db816b7

Please sign in to comment.