Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Add tests to api
Browse files Browse the repository at this point in the history
  • Loading branch information
failwiz committed Feb 8, 2024
1 parent ead7117 commit f15a9b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8==6.0.0 flake8-isort==6.0.0
pip install -r ./backend/requirements.txt
- name: Test with flake8
run: python -m flake8 backend/
run: |
python -m flake8 backend/
cd backend/
python manage.py test
21 changes: 21 additions & 0 deletions backend/api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from http import HTTPStatus

from api import models
from django.test import Client, TestCase


class TaskiAPITestCase(TestCase):
def setUp(self):
self.guest_client = Client()

def test_list_exists(self):
"""Проверка доступности списка задач."""
response = self.guest_client.get('/api/tasks/')
self.assertEqual(response.status_code, HTTPStatus.OK)

def test_task_creation(self):
"""Проверка создания задачи."""
data = {'title': 'Test', 'description': 'Test'}
response = self.guest_client.post('/api/tasks/', data=data)
self.assertEqual(response.status_code, HTTPStatus.CREATED)
self.assertTrue(models.Task.objects.filter(title='Test').exists())

0 comments on commit f15a9b3

Please sign in to comment.