Skip to content

Commit

Permalink
Test with flake8 and Django tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DimWSL committed Jul 31, 2023
1 parent 062f799 commit 0e0d0bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ 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
# Запускаем flake8
- name: Test with flake8
- name: Test with flake8 and Django tests
# Вызываем flake8 и указываем ему,
# что нужно проверить файлы только в папке backend/
run: python -m flake8 backend/
run: |
python -m flake8 backend/
cd backend/
python manage.py test
20 changes: 20 additions & 0 deletions backend/api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 0e0d0bd

Please sign in to comment.