Skip to content

Commit 6f01a47

Browse files
committed
adding unittests for apis
1 parent b7977cf commit 6f01a47

File tree

5 files changed

+769
-12
lines changed

5 files changed

+769
-12
lines changed

pyproject.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ show_missing = true
6464
branch = true
6565
source = ["src/django_project"]
6666
omit = [
67-
"django_project/manage.py",
68-
"django_project/core/asgi.py",
69-
"django_project/core/wsgi.py",
70-
"django_project/*/scripts/*",
71-
"django_project/tests/*",
67+
"src/django_project/manage.py",
68+
"src/django_project/core/asgi.py",
69+
"src/django_project/core/wsgi.py",
70+
"src/django_project/*/scripts/*",
71+
"src/django_project/tests/*",
7272
]
7373

7474

@@ -97,7 +97,13 @@ filterwarnings = [
9797

9898
[tool.ruff]
9999
line-length = 120
100-
exclude = ["django_project/manage.py", "django_project/tests", "django_project/*/migrations", "django_project/*/scripts", "django_project/*/local_test"]
100+
exclude = [
101+
"src/django_project/manage.py",
102+
"src/django_project/tests",
103+
"src/django_project/*/migrations",
104+
"src/django_project/*/scripts",
105+
"src/django_project/*/local_test"
106+
]
101107

102108

103109
[tool.setuptools.packages.find]

src/django_project/core/settings.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
BASE_DIR = Path(__file__).resolve().parent.parent
2121

2222

23-
ENV_PATH = os.environ.get("ENV_PATH", f"{BASE_DIR.parent}/envs/.env.local")
23+
# ENV_PATH = os.environ.get("ENV_PATH", f"{BASE_DIR.parent}/envs/.env.local")
24+
ENV_PATH = os.environ.get("ENV_PATH")
2425
# now load the contents of the defined .env file
2526
env = environ.Env()
26-
if os.path.exists(ENV_PATH):
27+
if ENV_PATH and os.path.exists(ENV_PATH):
2728
print(f"loading ENV vars from {ENV_PATH}")
2829
environ.Env.read_env(ENV_PATH)
2930
else:
@@ -37,7 +38,7 @@
3738
SECRET_KEY = env.str("SECRET_KEY", "default_key-this_is_insecure_and_should_be_changed")
3839

3940
# SECURITY WARNING: don't run with debug turned on in production!
40-
DEBUG = env.bool("DEBUG", True)
41+
DEBUG = env.bool("DEBUG", False)
4142
DEPLOYMENT_ENV = env.str("DEPLOYMENT_ENV", "local")
4243

4344

@@ -274,7 +275,7 @@
274275
else ("rest_framework.permissions.IsAuthenticated",),
275276
"DEFAULT_AUTHENTICATION_CLASSES": (
276277
"rest_framework.authentication.TokenAuthentication",
277-
"rest_framework.authentication.SessionAuthentication",
278+
# "rest_framework.authentication.SessionAuthentication",
278279
)
279280
if DEBUG
280281
else ("rest_framework.authentication.TokenAuthentication",),

src/django_project/tests/unit/web/test_model_crud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
BASE_DIR = Path(__file__).parents[4]
1010
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
11+
os.environ.setdefault("ENV_PATH", "../envs/.env.test")
1112
django.setup()
1213
from model_bakery import baker # noqa: E402
1314

0 commit comments

Comments
 (0)