diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 070d137203..4cfb6c5b97 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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/ \ No newline at end of file + run: | + python -m flake8 backend/ + cd backend/ + python manage.py test \ No newline at end of file diff --git a/backend/api/tests.py b/backend/api/tests.py new file mode 100644 index 0000000000..599e2e4f50 --- /dev/null +++ b/backend/api/tests.py @@ -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())