From c5a7d05714064fcbc4fefa5e3dd0bc1bf727b59e Mon Sep 17 00:00:00 2001 From: chestnut90 Date: Mon, 30 Oct 2023 14:46:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?:hammer:Chore=20:=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20Root=EC=99=80=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=A0=9D=ED=8A=B8=20Root=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 개발 환경 구성을 위한 project root와 repository root 분리 - repository root : git, docker, readme 등 환경 및 개발 구성 파일 포함 - project root(src) : 장고 project 포함 --- {common => src/common}/__init__.py | 0 {common => src/common}/apps.py | 0 {common => src/common}/decorator.py | 0 {common => src/common}/exceptions.py | 0 {common => src/common}/tests/__init__.py | 0 {common => src/common}/tests/decorator/__init__.py | 0 .../tests/decorator/test_query_parameter_decorator.py | 0 {common => src/common}/tests/utils/__init__.py | 0 {common => src/common}/tests/utils/test_date_utils.py | 0 {common => src/common}/urls.py | 0 {common => src/common}/utils.py | 0 {common => src/common}/views.py | 0 {config => src/config}/__init__.py | 0 {config => src/config}/asgi.py | 0 {config => src/config}/settings.py | 3 ++- {config => src/config}/urls.py | 10 ++++------ {config => src/config}/wsgi.py | 0 {likes => src/likes}/__init__.py | 0 {likes => src/likes}/apps.py | 0 {likes => src/likes}/migrations/__init__.py | 0 {likes => src/likes}/serializers.py | 0 {likes => src/likes}/tests.py | 0 {likes => src/likes}/urls.py | 0 {likes => src/likes}/views.py | 0 manage.py => src/manage.py | 0 {posts => src/posts}/__init__.py | 0 {posts => src/posts}/admin.py | 0 {posts => src/posts}/apps.py | 0 {posts => src/posts}/filters.py | 0 {posts => src/posts}/migrations/0001_initial.py | 0 .../posts}/migrations/0002_post_content_id.py | 0 {posts => src/posts}/migrations/__init__.py | 0 {posts => src/posts}/models.py | 0 {posts => src/posts}/paginations.py | 0 {posts => src/posts}/serializers.py | 0 {posts => src/posts}/tests/__init__.py | 0 {posts => src/posts}/tests/views/__init__.py | 0 .../posts}/tests/views/test_posts_list_view.py | 0 .../posts}/tests/views/test_statistics_list_view.py | 0 {posts => src/posts}/urls.py | 0 {posts => src/posts}/views.py | 0 {shares => src/shares}/__init__.py | 0 {shares => src/shares}/apps.py | 0 {shares => src/shares}/migrations/__init__.py | 0 {shares => src/shares}/tests.py | 0 {shares => src/shares}/views.py | 0 {users => src/users}/__init__.py | 0 {users => src/users}/admin.py | 0 {users => src/users}/apps.py | 0 {users => src/users}/managers.py | 0 {users => src/users}/migrations/0001_initial.py | 0 {users => src/users}/migrations/0002_user_username.py | 0 {users => src/users}/migrations/__init__.py | 0 {users => src/users}/models.py | 0 {users => src/users}/serializers.py | 0 {users => src/users}/tests/__init__.py | 0 {users => src/users}/tests/views/__init__.py | 0 {users => src/users}/tests/views/test_signup_view.py | 0 {users => src/users}/urls.py | 0 {users => src/users}/views.py | 0 60 files changed, 6 insertions(+), 7 deletions(-) rename {common => src/common}/__init__.py (100%) rename {common => src/common}/apps.py (100%) rename {common => src/common}/decorator.py (100%) rename {common => src/common}/exceptions.py (100%) rename {common => src/common}/tests/__init__.py (100%) rename {common => src/common}/tests/decorator/__init__.py (100%) rename {common => src/common}/tests/decorator/test_query_parameter_decorator.py (100%) rename {common => src/common}/tests/utils/__init__.py (100%) rename {common => src/common}/tests/utils/test_date_utils.py (100%) rename {common => src/common}/urls.py (100%) rename {common => src/common}/utils.py (100%) rename {common => src/common}/views.py (100%) rename {config => src/config}/__init__.py (100%) rename {config => src/config}/asgi.py (100%) rename {config => src/config}/settings.py (99%) rename {config => src/config}/urls.py (96%) rename {config => src/config}/wsgi.py (100%) rename {likes => src/likes}/__init__.py (100%) rename {likes => src/likes}/apps.py (100%) rename {likes => src/likes}/migrations/__init__.py (100%) rename {likes => src/likes}/serializers.py (100%) rename {likes => src/likes}/tests.py (100%) rename {likes => src/likes}/urls.py (100%) rename {likes => src/likes}/views.py (100%) rename manage.py => src/manage.py (100%) rename {posts => src/posts}/__init__.py (100%) rename {posts => src/posts}/admin.py (100%) rename {posts => src/posts}/apps.py (100%) rename {posts => src/posts}/filters.py (100%) rename {posts => src/posts}/migrations/0001_initial.py (100%) rename {posts => src/posts}/migrations/0002_post_content_id.py (100%) rename {posts => src/posts}/migrations/__init__.py (100%) rename {posts => src/posts}/models.py (100%) rename {posts => src/posts}/paginations.py (100%) rename {posts => src/posts}/serializers.py (100%) rename {posts => src/posts}/tests/__init__.py (100%) rename {posts => src/posts}/tests/views/__init__.py (100%) rename {posts => src/posts}/tests/views/test_posts_list_view.py (100%) rename {posts => src/posts}/tests/views/test_statistics_list_view.py (100%) rename {posts => src/posts}/urls.py (100%) rename {posts => src/posts}/views.py (100%) rename {shares => src/shares}/__init__.py (100%) rename {shares => src/shares}/apps.py (100%) rename {shares => src/shares}/migrations/__init__.py (100%) rename {shares => src/shares}/tests.py (100%) rename {shares => src/shares}/views.py (100%) rename {users => src/users}/__init__.py (100%) rename {users => src/users}/admin.py (100%) rename {users => src/users}/apps.py (100%) rename {users => src/users}/managers.py (100%) rename {users => src/users}/migrations/0001_initial.py (100%) rename {users => src/users}/migrations/0002_user_username.py (100%) rename {users => src/users}/migrations/__init__.py (100%) rename {users => src/users}/models.py (100%) rename {users => src/users}/serializers.py (100%) rename {users => src/users}/tests/__init__.py (100%) rename {users => src/users}/tests/views/__init__.py (100%) rename {users => src/users}/tests/views/test_signup_view.py (100%) rename {users => src/users}/urls.py (100%) rename {users => src/users}/views.py (100%) diff --git a/common/__init__.py b/src/common/__init__.py similarity index 100% rename from common/__init__.py rename to src/common/__init__.py diff --git a/common/apps.py b/src/common/apps.py similarity index 100% rename from common/apps.py rename to src/common/apps.py diff --git a/common/decorator.py b/src/common/decorator.py similarity index 100% rename from common/decorator.py rename to src/common/decorator.py diff --git a/common/exceptions.py b/src/common/exceptions.py similarity index 100% rename from common/exceptions.py rename to src/common/exceptions.py diff --git a/common/tests/__init__.py b/src/common/tests/__init__.py similarity index 100% rename from common/tests/__init__.py rename to src/common/tests/__init__.py diff --git a/common/tests/decorator/__init__.py b/src/common/tests/decorator/__init__.py similarity index 100% rename from common/tests/decorator/__init__.py rename to src/common/tests/decorator/__init__.py diff --git a/common/tests/decorator/test_query_parameter_decorator.py b/src/common/tests/decorator/test_query_parameter_decorator.py similarity index 100% rename from common/tests/decorator/test_query_parameter_decorator.py rename to src/common/tests/decorator/test_query_parameter_decorator.py diff --git a/common/tests/utils/__init__.py b/src/common/tests/utils/__init__.py similarity index 100% rename from common/tests/utils/__init__.py rename to src/common/tests/utils/__init__.py diff --git a/common/tests/utils/test_date_utils.py b/src/common/tests/utils/test_date_utils.py similarity index 100% rename from common/tests/utils/test_date_utils.py rename to src/common/tests/utils/test_date_utils.py diff --git a/common/urls.py b/src/common/urls.py similarity index 100% rename from common/urls.py rename to src/common/urls.py diff --git a/common/utils.py b/src/common/utils.py similarity index 100% rename from common/utils.py rename to src/common/utils.py diff --git a/common/views.py b/src/common/views.py similarity index 100% rename from common/views.py rename to src/common/views.py diff --git a/config/__init__.py b/src/config/__init__.py similarity index 100% rename from config/__init__.py rename to src/config/__init__.py diff --git a/config/asgi.py b/src/config/asgi.py similarity index 100% rename from config/asgi.py rename to src/config/asgi.py diff --git a/config/settings.py b/src/config/settings.py similarity index 99% rename from config/settings.py rename to src/config/settings.py index 0970411..b1e1ffc 100644 --- a/config/settings.py +++ b/src/config/settings.py @@ -1,6 +1,7 @@ +import os from pathlib import Path + import environ -import os BASE_DIR = Path(__file__).resolve().parent.parent diff --git a/config/urls.py b/src/config/urls.py similarity index 96% rename from config/urls.py rename to src/config/urls.py index 76d2b78..550ec5a 100644 --- a/config/urls.py +++ b/src/config/urls.py @@ -1,12 +1,10 @@ -from rest_framework import permissions - -from django.contrib import admin -from django.urls import path, include from django.conf import settings from django.conf.urls.static import static - -from drf_yasg.views import get_schema_view +from django.contrib import admin +from django.urls import include, path from drf_yasg import openapi +from drf_yasg.views import get_schema_view +from rest_framework import permissions schema_view = get_schema_view( openapi.Info( diff --git a/config/wsgi.py b/src/config/wsgi.py similarity index 100% rename from config/wsgi.py rename to src/config/wsgi.py diff --git a/likes/__init__.py b/src/likes/__init__.py similarity index 100% rename from likes/__init__.py rename to src/likes/__init__.py diff --git a/likes/apps.py b/src/likes/apps.py similarity index 100% rename from likes/apps.py rename to src/likes/apps.py diff --git a/likes/migrations/__init__.py b/src/likes/migrations/__init__.py similarity index 100% rename from likes/migrations/__init__.py rename to src/likes/migrations/__init__.py diff --git a/likes/serializers.py b/src/likes/serializers.py similarity index 100% rename from likes/serializers.py rename to src/likes/serializers.py diff --git a/likes/tests.py b/src/likes/tests.py similarity index 100% rename from likes/tests.py rename to src/likes/tests.py diff --git a/likes/urls.py b/src/likes/urls.py similarity index 100% rename from likes/urls.py rename to src/likes/urls.py diff --git a/likes/views.py b/src/likes/views.py similarity index 100% rename from likes/views.py rename to src/likes/views.py diff --git a/manage.py b/src/manage.py similarity index 100% rename from manage.py rename to src/manage.py diff --git a/posts/__init__.py b/src/posts/__init__.py similarity index 100% rename from posts/__init__.py rename to src/posts/__init__.py diff --git a/posts/admin.py b/src/posts/admin.py similarity index 100% rename from posts/admin.py rename to src/posts/admin.py diff --git a/posts/apps.py b/src/posts/apps.py similarity index 100% rename from posts/apps.py rename to src/posts/apps.py diff --git a/posts/filters.py b/src/posts/filters.py similarity index 100% rename from posts/filters.py rename to src/posts/filters.py diff --git a/posts/migrations/0001_initial.py b/src/posts/migrations/0001_initial.py similarity index 100% rename from posts/migrations/0001_initial.py rename to src/posts/migrations/0001_initial.py diff --git a/posts/migrations/0002_post_content_id.py b/src/posts/migrations/0002_post_content_id.py similarity index 100% rename from posts/migrations/0002_post_content_id.py rename to src/posts/migrations/0002_post_content_id.py diff --git a/posts/migrations/__init__.py b/src/posts/migrations/__init__.py similarity index 100% rename from posts/migrations/__init__.py rename to src/posts/migrations/__init__.py diff --git a/posts/models.py b/src/posts/models.py similarity index 100% rename from posts/models.py rename to src/posts/models.py diff --git a/posts/paginations.py b/src/posts/paginations.py similarity index 100% rename from posts/paginations.py rename to src/posts/paginations.py diff --git a/posts/serializers.py b/src/posts/serializers.py similarity index 100% rename from posts/serializers.py rename to src/posts/serializers.py diff --git a/posts/tests/__init__.py b/src/posts/tests/__init__.py similarity index 100% rename from posts/tests/__init__.py rename to src/posts/tests/__init__.py diff --git a/posts/tests/views/__init__.py b/src/posts/tests/views/__init__.py similarity index 100% rename from posts/tests/views/__init__.py rename to src/posts/tests/views/__init__.py diff --git a/posts/tests/views/test_posts_list_view.py b/src/posts/tests/views/test_posts_list_view.py similarity index 100% rename from posts/tests/views/test_posts_list_view.py rename to src/posts/tests/views/test_posts_list_view.py diff --git a/posts/tests/views/test_statistics_list_view.py b/src/posts/tests/views/test_statistics_list_view.py similarity index 100% rename from posts/tests/views/test_statistics_list_view.py rename to src/posts/tests/views/test_statistics_list_view.py diff --git a/posts/urls.py b/src/posts/urls.py similarity index 100% rename from posts/urls.py rename to src/posts/urls.py diff --git a/posts/views.py b/src/posts/views.py similarity index 100% rename from posts/views.py rename to src/posts/views.py diff --git a/shares/__init__.py b/src/shares/__init__.py similarity index 100% rename from shares/__init__.py rename to src/shares/__init__.py diff --git a/shares/apps.py b/src/shares/apps.py similarity index 100% rename from shares/apps.py rename to src/shares/apps.py diff --git a/shares/migrations/__init__.py b/src/shares/migrations/__init__.py similarity index 100% rename from shares/migrations/__init__.py rename to src/shares/migrations/__init__.py diff --git a/shares/tests.py b/src/shares/tests.py similarity index 100% rename from shares/tests.py rename to src/shares/tests.py diff --git a/shares/views.py b/src/shares/views.py similarity index 100% rename from shares/views.py rename to src/shares/views.py diff --git a/users/__init__.py b/src/users/__init__.py similarity index 100% rename from users/__init__.py rename to src/users/__init__.py diff --git a/users/admin.py b/src/users/admin.py similarity index 100% rename from users/admin.py rename to src/users/admin.py diff --git a/users/apps.py b/src/users/apps.py similarity index 100% rename from users/apps.py rename to src/users/apps.py diff --git a/users/managers.py b/src/users/managers.py similarity index 100% rename from users/managers.py rename to src/users/managers.py diff --git a/users/migrations/0001_initial.py b/src/users/migrations/0001_initial.py similarity index 100% rename from users/migrations/0001_initial.py rename to src/users/migrations/0001_initial.py diff --git a/users/migrations/0002_user_username.py b/src/users/migrations/0002_user_username.py similarity index 100% rename from users/migrations/0002_user_username.py rename to src/users/migrations/0002_user_username.py diff --git a/users/migrations/__init__.py b/src/users/migrations/__init__.py similarity index 100% rename from users/migrations/__init__.py rename to src/users/migrations/__init__.py diff --git a/users/models.py b/src/users/models.py similarity index 100% rename from users/models.py rename to src/users/models.py diff --git a/users/serializers.py b/src/users/serializers.py similarity index 100% rename from users/serializers.py rename to src/users/serializers.py diff --git a/users/tests/__init__.py b/src/users/tests/__init__.py similarity index 100% rename from users/tests/__init__.py rename to src/users/tests/__init__.py diff --git a/users/tests/views/__init__.py b/src/users/tests/views/__init__.py similarity index 100% rename from users/tests/views/__init__.py rename to src/users/tests/views/__init__.py diff --git a/users/tests/views/test_signup_view.py b/src/users/tests/views/test_signup_view.py similarity index 100% rename from users/tests/views/test_signup_view.py rename to src/users/tests/views/test_signup_view.py diff --git a/users/urls.py b/src/users/urls.py similarity index 100% rename from users/urls.py rename to src/users/urls.py diff --git a/users/views.py b/src/users/views.py similarity index 100% rename from users/views.py rename to src/users/views.py From 7d0ba996a456004a8c854649764705a50eb81937 Mon Sep 17 00:00:00 2001 From: chestnut90 Date: Mon, 30 Oct 2023 14:51:24 +0900 Subject: [PATCH 2/5] =?UTF-8?q?:hammer:Chore=20:=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=EB=B6=84=EB=A6=AC=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20Docker=20=EB=B0=8F=20CI=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - repository root와 project root가 분리 되면서 Docker 환경 세팅 - Dockerfile에서 /app/src/에 project를 프로젝트를 마운트하여 사용 - /app/pyproject.toml은 Poetry venv 활성화하기 위한 조건 --- .github/workflows/CI.yml | 4 ++-- Dockerfile | 7 +++---- docker-compose.yml | 7 +++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 60699e5..5e0e2e0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,7 @@ jobs: run: docker compose build - name: Migration test database - run: docker compose run django poetry run python manage.py migrate + run: docker compose run django poetry run python src/manage.py migrate - name: Run isort run: docker compose run django poetry run isort . --check @@ -26,4 +26,4 @@ jobs: run: docker compose run django poetry run flake8 - name: Run Test - run: docker compose run django poetry run python3 manage.py test + run: docker compose run django poetry run python3 src/manage.py test diff --git a/Dockerfile b/Dockerfile index d62171d..8b298b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,9 @@ RUN python3 -m venv $POETRY_VENV \ ENV PATH="${PATH}:${POETRY_VENV}/bin" RUN mkdir /app/ -WORKDIR /app/ +RUN mkdir /app/src/ +WORKDIR /app -COPY pyproject.toml ./ +COPY pyproject.toml /app/ RUN poetry install - -COPY . /app diff --git a/docker-compose.yml b/docker-compose.yml index 3d37262..8d895c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,9 +21,12 @@ services: build: context: . dockerfile: Dockerfile - command: poetry run python manage.py runserver 0.0.0.0:8000 + command: > + bash -c "poetry run python src/manage.py makemigrations && + poetry run python src/manage.py migrate && + poetry run python src/manage.py runserver 0.0.0.0:8000" volumes: - - .:/app + - ./src:/app/src/ environment: - POSTGRESQL_HOST=postgres ports: From 0a78df0828ca89cf5ef91b01c9a221c13cf97529 Mon Sep 17 00:00:00 2001 From: chestnut90 Date: Mon, 30 Oct 2023 15:58:14 +0900 Subject: [PATCH 3/5] =?UTF-8?q?:hammer:Chore=20:=20Docker=EC=97=90=20flake?= =?UTF-8?q?8=20option=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - flake8의 max-line-length, exclue에 대한 setup.cfg 파일 copy 적용 --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8b298b5..f5bd247 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,5 +17,6 @@ RUN mkdir /app/src/ WORKDIR /app COPY pyproject.toml /app/ +COPY setup.cfg /app/ RUN poetry install From 85034dbed322e5b06dd7b1e92ed6841b5d1b3ace Mon Sep 17 00:00:00 2001 From: chestnut90 Date: Tue, 31 Oct 2023 11:51:31 +0900 Subject: [PATCH 4/5] =?UTF-8?q?:fire:Remove=20:=20Share=20app=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20global=20test=20case=20=EC=A0=9C=EA=B1=B0?= =?UTF-8?q?=20#12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - tests.py 제거. Related to #12 --- src/shares/tests.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/shares/tests.py diff --git a/src/shares/tests.py b/src/shares/tests.py deleted file mode 100644 index a39b155..0000000 --- a/src/shares/tests.py +++ /dev/null @@ -1 +0,0 @@ -# Create your tests here. From e072947f0d6ff47ffa9f117e0493ee261913743c Mon Sep 17 00:00:00 2001 From: chestnut90 Date: Tue, 31 Oct 2023 11:53:40 +0900 Subject: [PATCH 5/5] =?UTF-8?q?:fire:Remove=20:=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20list=20api=20test=EC=97=90=20=EB=8C=80=ED=95=9C=20p?= =?UTF-8?q?rint()=20=EC=A0=9C=EA=B1=B0=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 테스트 케이스에 Print문 존재 Related to #9 --- src/posts/tests/views/test_posts_list_view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/posts/tests/views/test_posts_list_view.py b/src/posts/tests/views/test_posts_list_view.py index e4475af..7174dec 100644 --- a/src/posts/tests/views/test_posts_list_view.py +++ b/src/posts/tests/views/test_posts_list_view.py @@ -59,7 +59,7 @@ def test_get_posts_list_success(self): path=reverse("list"), data={"type": "all", "hashtag": self.hashtag1.id, "ordering": "created_at", "search": ""}, ) - print(response.data) # 서버의 응답 내용 출력 + self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data), 4) # 예상되는 게시물 개수 확인 for item in response.data: