From ea14cbd9d2fdbae038f45e7172b6909f6035cf22 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:04:00 +0300 Subject: [PATCH 01/29] Create main.yml --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..18a6a3e3d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From dd8e52c43322453e87d51e24911f50b14f8ac80a Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:15:34 +0300 Subject: [PATCH 02/29] New main.yml --- .github/workflows/main.yml | 50 +++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18a6a3e3d..f56034105 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,36 +1,30 @@ -# This is a basic workflow to help you get started with Actions +name: Django-app workflow -name: CI +on: [push] -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the "main" branch - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on + tests: + # «Раннер» — создание изолированного окружения с последней версией Ubuntu runs-on: ubuntu-latest - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + # Запуск actions checkout — готового скрипта + # для клонирования репозитория + - uses: actions/checkout@v2 + - name: Set up Python + # Запуск actions setup-python — готового скрипта + # для развёртывания окружения Python + uses: actions/setup-python@v2 + with: + # Выбор версии Python + python-version: 3.7 - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort + pip install -r requirements.txt - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. + - name: Test with flake8 and django tests + run: | + python -m flake8 \ No newline at end of file From d57056ab257b4ba79d026f70d39b89e4fb5d2e72 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:21:21 +0300 Subject: [PATCH 03/29] New setup.cfg --- setup.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..9e61d1f17 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,12 @@ +[flake8] +ignore = + W503, + F811 +exclude = + tests/, + */migrations/, + venv/, + env/ +per-file-ignores = + */settings.py:E501 +max-complexity = 10 From 2b4c33c1ece59af485f29dd9d109f3eeb5c7e71a Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:30:26 +0300 Subject: [PATCH 04/29] 1 --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f56034105..68397ce67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,4 @@ +# .github/workflows/**main.yml** name: Django-app workflow on: [push] @@ -21,10 +22,14 @@ jobs: - name: Install dependencies run: | + # обновление pip python -m pip install --upgrade pip + # установка flake8 и его плагинов pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort + # установка зависимостей pip install -r requirements.txt - name: Test with flake8 and django tests run: | + # запуск проверки проекта по flake8 python -m flake8 \ No newline at end of file From 5d76923f35f1c3f5f0c36c10674b78d6e490f419 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:41:51 +0300 Subject: [PATCH 05/29] 2 --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 9e61d1f17..145088e3b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,3 +10,4 @@ exclude = per-file-ignores = */settings.py:E501 max-complexity = 10 + From 4dd0df63a5db9773c02e41de4c4b9d76a958b8a2 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:44:56 +0300 Subject: [PATCH 06/29] 3 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 68397ce67..d33fac9cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: run: | # обновление pip python -m pip install --upgrade pip - # установка flake8 и его плагинов + pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort # установка зависимостей pip install -r requirements.txt From e2d83ec78f42ac8cad2f70f9302cdd98b6d63021 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:54:32 +0300 Subject: [PATCH 07/29] 4 --- .gitignore | 2 +- Dockerfile | 1 + infra_project/infra_project/settings.py | 12 ------------ infra_project/manage.py | 1 - setup.cfg | 1 - 5 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 2bbfacb63..5eb27bea6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ __pycache__/ .vscode/ *.code-workspace -# C extensions + *.so # Distribution / packaging diff --git a/Dockerfile b/Dockerfile index 2417c0d66..9de927afd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,3 +3,4 @@ COPY ./ /app RUN pip install -r /app/requirements.txt WORKDIR /app/infra_project/ CMD python manage.py runserver 0:5000 + diff --git a/infra_project/infra_project/settings.py b/infra_project/infra_project/settings.py index 012b314ae..7ae688b89 100644 --- a/infra_project/infra_project/settings.py +++ b/infra_project/infra_project/settings.py @@ -1,15 +1,3 @@ -""" -Django settings for infra_project project. - -Generated by 'django-admin startproject' using Django 2.2.20. - -For more information on this file, see -https://docs.djangoproject.com/en/2.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.2/ref/settings/ -""" - import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) diff --git a/infra_project/manage.py b/infra_project/manage.py index 82ee86cfa..8cd518d4e 100644 --- a/infra_project/manage.py +++ b/infra_project/manage.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" import os import sys diff --git a/setup.cfg b/setup.cfg index 145088e3b..9e61d1f17 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,4 +10,3 @@ exclude = per-file-ignores = */settings.py:E501 max-complexity = 10 - From f4dfca30ae7be1503aae5c63ef834eec26276234 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:57:11 +0300 Subject: [PATCH 08/29] 5 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 9e61d1f17..52cdd9f7a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,4 +9,4 @@ exclude = env/ per-file-ignores = */settings.py:E501 -max-complexity = 10 +max-complexity = 10 \ No newline at end of file From 9bbcffcca1e4341215a07bfd2652276066dc7d78 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:28:49 +0300 Subject: [PATCH 09/29] 6 --- infra_project/infra_app/tests.py | 1 + setup.cfg | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 77c89862c..dc049b18d 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,4 +1,5 @@ from http import HTTPStatus + from django.test import Client, TestCase diff --git a/setup.cfg b/setup.cfg index 52cdd9f7a..db5ee8ba2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,10 +3,11 @@ ignore = W503, F811 exclude = - tests/, + */tests/, */migrations/, venv/, - env/ + env/, + */infra_project/urls.py per-file-ignores = */settings.py:E501 max-complexity = 10 \ No newline at end of file From d1f0866980a92d8aafe1a7cd7b4465952e189e8c Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:33:02 +0300 Subject: [PATCH 10/29] 7 --- .github/workflows/main.yml | 19 +++++++++---------- infra_project/infra_app/tests.py | 7 ++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d33fac9cc..226c4c807 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,30 +1,23 @@ -# .github/workflows/**main.yml** name: Django-app workflow on: [push] jobs: tests: - # «Раннер» — создание изолированного окружения с последней версией Ubuntu runs-on: ubuntu-latest steps: - # Запуск actions checkout — готового скрипта - # для клонирования репозитория - uses: actions/checkout@v2 - - name: Set up Python - # Запуск actions setup-python — готового скрипта - # для развёртывания окружения Python + - name: Set up Python uses: actions/setup-python@v2 with: - # Выбор версии Python python-version: 3.7 - name: Install dependencies run: | # обновление pip python -m pip install --upgrade pip - + # установка flake8 и его плагинов pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort # установка зависимостей pip install -r requirements.txt @@ -32,4 +25,10 @@ jobs: - name: Test with flake8 and django tests run: | # запуск проверки проекта по flake8 - python -m flake8 \ No newline at end of file + python -m flake8 + # перейти в папку, содержащую manage.py — + #<корневая_папка_infra_actions>/<папка_проекта>/manage.py + cd infra_project/ + # запустить написанные разработчиком тесты + python manage.py test + diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index dc049b18d..d50b90d6a 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,8 +1,8 @@ -from http import HTTPStatus +# infra_project/infra_app/tests.py +from http import HTTPStatus from django.test import Client, TestCase - class StaticPagesURLTests(TestCase): def setUp(self): self.guest_client = Client() @@ -21,4 +21,5 @@ def test_page_shows_correct_content(self): self.assertContains(response, 'У меня получилось!') response = self.guest_client.get('/second_page/') - self.assertContains(response, 'А это вторая страница!') + self.assertContains(response, 'А это вторая страница') + From 0a50e944e3f1ef5bbc16a9bba9277a6b3e2c8fb6 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:35:45 +0300 Subject: [PATCH 11/29] 8 --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index db5ee8ba2..23e7e449b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,7 @@ exclude = venv/, env/, */infra_project/urls.py + */infra_app/tests.py per-file-ignores = */settings.py:E501 max-complexity = 10 \ No newline at end of file From da3f57e8e82179fdfea0434ed60a631a185e6698 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:38:04 +0300 Subject: [PATCH 12/29] 9 --- infra_project/infra_app/tests.py | 3 ++- setup.cfg | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index d50b90d6a..5e8ae50db 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,8 +1,10 @@ # infra_project/infra_app/tests.py from http import HTTPStatus + from django.test import Client, TestCase + class StaticPagesURLTests(TestCase): def setUp(self): self.guest_client = Client() @@ -22,4 +24,3 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/second_page/') self.assertContains(response, 'А это вторая страница') - diff --git a/setup.cfg b/setup.cfg index 23e7e449b..5ac266bce 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,7 +8,7 @@ exclude = venv/, env/, */infra_project/urls.py - */infra_app/tests.py + # */infra_app/tests.py per-file-ignores = */settings.py:E501 max-complexity = 10 \ No newline at end of file From 682473974df55d63c98db9bac1a978cab1db0d01 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:39:47 +0300 Subject: [PATCH 13/29] 10 --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5ac266bce..d7b21ade8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,8 +7,8 @@ exclude = */migrations/, venv/, env/, - */infra_project/urls.py - # */infra_app/tests.py + */infra_project/urls.py, + */infra_app/tests.py per-file-ignores = */settings.py:E501 max-complexity = 10 \ No newline at end of file From cc1029b9d8735985f9be7252d7da90b25e9fc691 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:45:33 +0300 Subject: [PATCH 14/29] 11 --- setup.cfg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index d7b21ade8..64f2d180f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,12 +3,11 @@ ignore = W503, F811 exclude = - */tests/, + tests/, */migrations/, venv/, env/, - */infra_project/urls.py, - */infra_app/tests.py + */infra_project/urls.py per-file-ignores = */settings.py:E501 -max-complexity = 10 \ No newline at end of file +max-complexity = 10 From 39dab5a22e92a2efc8f6ab7a5e815e7c9f1711f3 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:51:45 +0300 Subject: [PATCH 15/29] 12 --- infra_project/infra_app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 5e8ae50db..d6e4e2fea 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -12,10 +12,10 @@ def setUp(self): def test_about_url_exists_at_desired_location(self): """Проверка доступности страниц.""" response = self.guest_client.get('/') - self.assertEqual(response.status_code, HTTPStatus.OK) + self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) response = self.guest_client.get('/second_page/') - self.assertEqual(response.status_code, HTTPStatus.OK) + self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) def test_page_shows_correct_content(self): """Проверка контента страниц.""" From 82fbd74515dd9abaf12c805178a01ea48f8433f9 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:53:08 +0300 Subject: [PATCH 16/29] 13 --- infra_project/infra_app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index d6e4e2fea..5e8ae50db 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -12,10 +12,10 @@ def setUp(self): def test_about_url_exists_at_desired_location(self): """Проверка доступности страниц.""" response = self.guest_client.get('/') - self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) + self.assertEqual(response.status_code, HTTPStatus.OK) response = self.guest_client.get('/second_page/') - self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) + self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): """Проверка контента страниц.""" From 0e15ce67626ffbe22fe18787ee80f0bbbc740240 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 18:58:14 +0300 Subject: [PATCH 17/29] 13 --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 226c4c807..f3c509156 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,4 +31,3 @@ jobs: cd infra_project/ # запустить написанные разработчиком тесты python manage.py test - From e400dfc5410cf146a7f143dd08a592d0164d85be Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 19:10:05 +0300 Subject: [PATCH 18/29] 15 --- infra_project/infra_app/tests.py | 4 ++-- infra_project/infra_app/urls.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 5e8ae50db..8c06a2e6f 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -14,7 +14,7 @@ def test_about_url_exists_at_desired_location(self): response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('/second_page/') + response = self.guest_client.get('/second/') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): @@ -22,5 +22,5 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('/second_page/') + response = self.guest_client.get('/second/') self.assertContains(response, 'А это вторая страница') diff --git a/infra_project/infra_app/urls.py b/infra_project/infra_app/urls.py index 416b10259..45a0f19aa 100644 --- a/infra_project/infra_app/urls.py +++ b/infra_project/infra_app/urls.py @@ -5,7 +5,7 @@ app_name = 'infra_app' urlpatterns = [ - path('', views.index, name='index'), - path('second/', views.second_page, name='second_page'), + path('/', views.index, name='index'), + path('/second/', views.second_page, name='second_page'), ] From ac14e39a428925f890b9b6051785ef7667f5dd57 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 19:12:11 +0300 Subject: [PATCH 19/29] 17 --- infra_project/infra_app/tests.py | 4 ++-- infra_project/infra_app/urls.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 8c06a2e6f..6a730dd48 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -14,7 +14,7 @@ def test_about_url_exists_at_desired_location(self): response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('/second/') + response = self.guest_client.get('second/') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): @@ -22,5 +22,5 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('/second/') + response = self.guest_client.get('second/') self.assertContains(response, 'А это вторая страница') diff --git a/infra_project/infra_app/urls.py b/infra_project/infra_app/urls.py index 45a0f19aa..416b10259 100644 --- a/infra_project/infra_app/urls.py +++ b/infra_project/infra_app/urls.py @@ -5,7 +5,7 @@ app_name = 'infra_app' urlpatterns = [ - path('/', views.index, name='index'), - path('/second/', views.second_page, name='second_page'), + path('', views.index, name='index'), + path('second/', views.second_page, name='second_page'), ] From ca271c2c2ead589ea61c2692d267bb7267a538ff Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Sat, 23 Jul 2022 19:15:58 +0300 Subject: [PATCH 20/29] 18 --- infra_project/infra_app/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 6a730dd48..25a37726f 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -11,16 +11,16 @@ def setUp(self): def test_about_url_exists_at_desired_location(self): """Проверка доступности страниц.""" - response = self.guest_client.get('/') + response = self.guest_client.get('index') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('second/') + response = self.guest_client.get('second_page') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): """Проверка контента страниц.""" - response = self.guest_client.get('/') + response = self.guest_client.get('index') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('second/') + response = self.guest_client.get('second_page') self.assertContains(response, 'А это вторая страница') From 91f886d1e9221ebed6fe786ee820869a7a1efe60 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:11:25 +0300 Subject: [PATCH 21/29] 20 --- .github/workflows/main.yml | 16 +++++++++------- infra_project/infra_app/tests.py | 11 +++++------ infra_project/infra_project/urls.py | 1 - 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3c509156..68397ce67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,16 +1,23 @@ +# .github/workflows/**main.yml** name: Django-app workflow on: [push] jobs: tests: + # «Раннер» — создание изолированного окружения с последней версией Ubuntu runs-on: ubuntu-latest steps: + # Запуск actions checkout — готового скрипта + # для клонирования репозитория - uses: actions/checkout@v2 - - name: Set up Python + - name: Set up Python + # Запуск actions setup-python — готового скрипта + # для развёртывания окружения Python uses: actions/setup-python@v2 with: + # Выбор версии Python python-version: 3.7 - name: Install dependencies @@ -25,9 +32,4 @@ jobs: - name: Test with flake8 and django tests run: | # запуск проверки проекта по flake8 - python -m flake8 - # перейти в папку, содержащую manage.py — - #<корневая_папка_infra_actions>/<папка_проекта>/manage.py - cd infra_project/ - # запустить написанные разработчиком тесты - python manage.py test + python -m flake8 \ No newline at end of file diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 25a37726f..d50b90d6a 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,26 +1,25 @@ # infra_project/infra_app/tests.py from http import HTTPStatus - from django.test import Client, TestCase - class StaticPagesURLTests(TestCase): def setUp(self): self.guest_client = Client() def test_about_url_exists_at_desired_location(self): """Проверка доступности страниц.""" - response = self.guest_client.get('index') + response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('second_page') + response = self.guest_client.get('/second_page/') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): """Проверка контента страниц.""" - response = self.guest_client.get('index') + response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('second_page') + response = self.guest_client.get('/second_page/') self.assertContains(response, 'А это вторая страница') + diff --git a/infra_project/infra_project/urls.py b/infra_project/infra_project/urls.py index 10c002bae..e49cf4311 100644 --- a/infra_project/infra_project/urls.py +++ b/infra_project/infra_project/urls.py @@ -1,5 +1,4 @@ """infra_project URL Configuration - The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: From 74c92934de2c5db9687407508365828f28b49341 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:16:37 +0300 Subject: [PATCH 22/29] 21 --- infra_project/infra_app/tests.py | 6 ++---- infra_project/infra_project/urls.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index d50b90d6a..406690f9f 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,8 +1,7 @@ -# infra_project/infra_app/tests.py - from http import HTTPStatus from django.test import Client, TestCase + class StaticPagesURLTests(TestCase): def setUp(self): self.guest_client = Client() @@ -21,5 +20,4 @@ def test_page_shows_correct_content(self): self.assertContains(response, 'У меня получилось!') response = self.guest_client.get('/second_page/') - self.assertContains(response, 'А это вторая страница') - + self.assertContains(response, 'А это вторая страница!') \ No newline at end of file diff --git a/infra_project/infra_project/urls.py b/infra_project/infra_project/urls.py index e49cf4311..59d34c139 100644 --- a/infra_project/infra_project/urls.py +++ b/infra_project/infra_project/urls.py @@ -13,7 +13,7 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path('', include('infra_app.urls', namespace='infra_app')), From 6830d3f966299a0afb4c2d5914f4d4e9317ef4c2 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:17:36 +0300 Subject: [PATCH 23/29] 21 --- infra_project/infra_app/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 406690f9f..dc049b18d 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,4 +1,5 @@ from http import HTTPStatus + from django.test import Client, TestCase @@ -20,4 +21,4 @@ def test_page_shows_correct_content(self): self.assertContains(response, 'У меня получилось!') response = self.guest_client.get('/second_page/') - self.assertContains(response, 'А это вторая страница!') \ No newline at end of file + self.assertContains(response, 'А это вторая страница!') From e7cf05d0f676673e5935bc363cfb9ffa4adc824a Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:22:22 +0300 Subject: [PATCH 24/29] 22 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 68397ce67..6cb0fb1dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,4 +32,4 @@ jobs: - name: Test with flake8 and django tests run: | # запуск проверки проекта по flake8 - python -m flake8 \ No newline at end of file + python -m flake8 From f8ba6a4fa3defa24bcb86d27464471e19c129c6a Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:24:16 +0300 Subject: [PATCH 25/29] 23 --- setup.cfg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 64f2d180f..9e61d1f17 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,8 +6,7 @@ exclude = tests/, */migrations/, venv/, - env/, - */infra_project/urls.py + env/ per-file-ignores = */settings.py:E501 max-complexity = 10 From b3590f10bb59f01bf04baf3dd66982238ce87b22 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:28:15 +0300 Subject: [PATCH 26/29] 24 --- .github/workflows/main.yml | 15 +++++++-------- infra_project/infra_app/tests.py | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6cb0fb1dd..226c4c807 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,23 +1,16 @@ -# .github/workflows/**main.yml** name: Django-app workflow on: [push] jobs: tests: - # «Раннер» — создание изолированного окружения с последней версией Ubuntu runs-on: ubuntu-latest steps: - # Запуск actions checkout — готового скрипта - # для клонирования репозитория - uses: actions/checkout@v2 - - name: Set up Python - # Запуск actions setup-python — готового скрипта - # для развёртывания окружения Python + - name: Set up Python uses: actions/setup-python@v2 with: - # Выбор версии Python python-version: 3.7 - name: Install dependencies @@ -33,3 +26,9 @@ jobs: run: | # запуск проверки проекта по flake8 python -m flake8 + # перейти в папку, содержащую manage.py — + #<корневая_папка_infra_actions>/<папка_проекта>/manage.py + cd infra_project/ + # запустить написанные разработчиком тесты + python manage.py test + diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index dc049b18d..5e8ae50db 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -1,3 +1,5 @@ +# infra_project/infra_app/tests.py + from http import HTTPStatus from django.test import Client, TestCase @@ -21,4 +23,4 @@ def test_page_shows_correct_content(self): self.assertContains(response, 'У меня получилось!') response = self.guest_client.get('/second_page/') - self.assertContains(response, 'А это вторая страница!') + self.assertContains(response, 'А это вторая страница') From 1569fbaf3dc910892f5a05320a2abd8645331cc6 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:42:29 +0300 Subject: [PATCH 27/29] 25 --- infra_project/infra_app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 5e8ae50db..e40354a79 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -14,7 +14,7 @@ def test_about_url_exists_at_desired_location(self): response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('/second_page/') + response = self.guest_client.get('second_page') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): @@ -22,5 +22,5 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('/second_page/') + response = self.guest_client.get('second_page') self.assertContains(response, 'А это вторая страница') From 6600338ac31d1fbd09e07be7522dd940af8e46a4 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:44:51 +0300 Subject: [PATCH 28/29] 26 --- infra_project/infra_app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index e40354a79..6a730dd48 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -14,7 +14,7 @@ def test_about_url_exists_at_desired_location(self): response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('second_page') + response = self.guest_client.get('second/') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): @@ -22,5 +22,5 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('second_page') + response = self.guest_client.get('second/') self.assertContains(response, 'А это вторая страница') From f373222304e86b625823b243eec380467ecd2fe9 Mon Sep 17 00:00:00 2001 From: SergKorn <96118130+SergKorn@users.noreply.github.com> Date: Fri, 29 Jul 2022 00:58:49 +0300 Subject: [PATCH 29/29] 27 --- infra_project/infra_app/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra_project/infra_app/tests.py b/infra_project/infra_app/tests.py index 6a730dd48..8c06a2e6f 100644 --- a/infra_project/infra_app/tests.py +++ b/infra_project/infra_app/tests.py @@ -14,7 +14,7 @@ def test_about_url_exists_at_desired_location(self): response = self.guest_client.get('/') self.assertEqual(response.status_code, HTTPStatus.OK) - response = self.guest_client.get('second/') + response = self.guest_client.get('/second/') self.assertEqual(response.status_code, HTTPStatus.OK) def test_page_shows_correct_content(self): @@ -22,5 +22,5 @@ def test_page_shows_correct_content(self): response = self.guest_client.get('/') self.assertContains(response, 'У меня получилось!') - response = self.guest_client.get('second/') + response = self.guest_client.get('/second/') self.assertContains(response, 'А это вторая страница')