added coverage dependency; 99 percent test coverage (only lacking admin, currently by design); commenced postgresql db integration
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,6 +1,16 @@
|
|||||||
|
services:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:16
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: python_tdd_test
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: test-UTs
|
- name: test-UTs-n-ITs
|
||||||
image: python:3.13-slim
|
image: python:3.13-slim
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgresql://postgres:postgres@postgres/python_tdd_test
|
||||||
commands:
|
commands:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- cd ./src
|
- cd ./src
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ attrs==25.4.0
|
|||||||
certifi==2025.11.12
|
certifi==2025.11.12
|
||||||
cffi==2.0.0
|
cffi==2.0.0
|
||||||
charset-normalizer==3.4.4
|
charset-normalizer==3.4.4
|
||||||
|
coverage
|
||||||
cssselect==1.3.0
|
cssselect==1.3.0
|
||||||
|
dj-database-url
|
||||||
Django==6.0
|
Django==6.0
|
||||||
django-stubs==5.2.8
|
django-stubs==5.2.8
|
||||||
django-stubs-ext==5.2.8
|
django-stubs-ext==5.2.8
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
cssselect==1.3.0
|
cssselect==1.3.0
|
||||||
Django==6.0
|
Django==6.0
|
||||||
|
dj-database-url
|
||||||
django-stubs==5.2.8
|
django-stubs==5.2.8
|
||||||
django-stubs-ext==5.2.8
|
django-stubs-ext==5.2.8
|
||||||
gunicorn==23.0.0
|
gunicorn==23.0.0
|
||||||
lxml==6.0.2
|
lxml==6.0.2
|
||||||
|
psycopg2-binary
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
whitenoise==6.11.0
|
whitenoise==6.11.0
|
||||||
|
|||||||
8
src/.coveragerc
Normal file
8
src/.coveragerc
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[run]
|
||||||
|
source = apps
|
||||||
|
omit =
|
||||||
|
*/migrations/*
|
||||||
|
*/tests/*
|
||||||
|
|
||||||
|
[report]
|
||||||
|
show_missing = true
|
||||||
@@ -10,3 +10,8 @@ class SimpleAuthenticateTest(SimpleTestCase):
|
|||||||
HttpRequest(), "no-such-token"
|
HttpRequest(), "no-such-token"
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_returns_None_if_no_uuid(self):
|
||||||
|
result = PasswordlessAuthenticationBackend().authenticate(HttpRequest())
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/6.0/ref/settings/
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
import dj_database_url
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -26,13 +27,11 @@ if 'DJANGO_DEBUG_FALSE' in os.environ:
|
|||||||
DEBUG = False
|
DEBUG = False
|
||||||
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
|
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
|
||||||
ALLOWED_HOSTS = [host.strip() for host in os.environ['DJANGO_ALLOWED_HOST'].split(',')]
|
ALLOWED_HOSTS = [host.strip() for host in os.environ['DJANGO_ALLOWED_HOST'].split(',')]
|
||||||
db_path = os.environ['DJANGO_DB_PATH']
|
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-&9b_h=qpjy=sshhnsyg98&jp7(t6*v78__y%h2l$b#_@6z$-9r'
|
SECRET_KEY = 'django-insecure-&9b_h=qpjy=sshhnsyg98&jp7(t6*v78__y%h2l$b#_@6z$-9r'
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
db_path = BASE_DIR / 'db.sqlite3'
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@@ -90,10 +89,14 @@ ASGI_APPLICATION = 'core.asgi.application'
|
|||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASE_URL = os.environ.get('DATABASE_URL')
|
||||||
|
if DATABASE_URL:
|
||||||
|
DATABASES = {'default': dj_database_url.config(conn_max_age=600)}
|
||||||
|
else:
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': db_path,
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user