diff --git a/.drone.yml b/.drone.yml index f0b9b36..da08f40 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,8 +10,9 @@ steps: image: python commands: - pip install -r requirements_test.txt - - ./scripts/setup.sh - - ./scripts/tests.sh + - ./scripts/CI/setup.sh + - ./scripts/CI/test.sh + - ./scripts/CI/lint.sh settings: username: diff --git a/lockbox/lockbox/settings.py b/lockbox/lockbox/settings.py index 53f85a0..dd62e96 100644 --- a/lockbox/lockbox/settings.py +++ b/lockbox/lockbox/settings.py @@ -11,10 +11,19 @@ load_dotenv() # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +# Configs loaded from env or defaults SECRET_KEY = get_config("SECRET_KEY") DEBUG = get_config("DEBUG") - ALLOWED_HOSTS = get_config("ALLOWED_HOSTS") +DB_SQLITE_ABSOLUTE_PATH = get_config("DB_SQLITE_ABSOLUTE_PATH") + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + }, +} + # Application definition @@ -64,19 +73,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'lockbox.wsgi.application' - -# Database - -DB_SQLITE_ABSOLUTE_PATH = get_config("DB_SQLITE_ABSOLUTE_PATH") - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - }, -} - - # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators @@ -110,7 +106,11 @@ STATICFILES_DIRS = [ ] STATIC_ROOT = BASE_DIR / "staticfiles" STATIC_URL = 'static/' -STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" +STORAGES = { + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + }, +} # Storage MEDIA_ROOT = BASE_DIR / "media" diff --git a/lockbox/storage/serializers.py b/lockbox/storage/serializers.py index 96601b0..5445205 100644 --- a/lockbox/storage/serializers.py +++ b/lockbox/storage/serializers.py @@ -23,6 +23,7 @@ class FileChunkSerializer(serializers.ModelSerializer): file = File.objects.get(lid=data["file"]) if data["size"] > file.max_size_chunk_bytes: - detail = f"'size' param is larger than max chunk size for file, {data["size"]} > {file.max_size_chunk_bytes}" + detail = f"'size' param is larger than max chunk size for file:\ + {data["size"]} > {file.max_size_chunk_bytes}" raise serializers.ValidationError(detail) return data diff --git a/lockbox/storage/views_api.py b/lockbox/storage/views_api.py index c1246cf..cc2a3dd 100644 --- a/lockbox/storage/views_api.py +++ b/lockbox/storage/views_api.py @@ -1,7 +1,8 @@ from common.constants import ( UPLOAD_STATUS_TYPES, ) -from common.utils import get_config + +# from common.utils import get_config from rest_framework import status from rest_framework.decorators import action from rest_framework.response import Response diff --git a/lockbox/user/tests/test_user.py b/lockbox/user/tests/test_user.py index d51d2f1..e7a9a41 100644 --- a/lockbox/user/tests/test_user.py +++ b/lockbox/user/tests/test_user.py @@ -1,5 +1,7 @@ import pytest +from user.models import LockboxUser + @pytest.mark.django_db() class TestUser: @@ -7,4 +9,6 @@ class TestUser: Test user related functions are working correctly. """ def test_stub(self): - assert True + user = LockboxUser.objects.create(alias="TestUser", username="meow") + loaded_user = LockboxUser.objects.filter(alias="TestUser").first() + assert user.lid == loaded_user.lid diff --git a/pyproject.toml b/pyproject.toml index 830bed4..a80347d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ exclude = [ ".pyenv*", ".git", ".venv", + "manage.py", ] force-exclude = true diff --git a/scripts/CI/lint.sh b/scripts/CI/lint.sh new file mode 100644 index 0000000..36dd2cf --- /dev/null +++ b/scripts/CI/lint.sh @@ -0,0 +1,2 @@ +cd lockbox +ruff check --config=./pyproject.toml \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/CI/setup.sh similarity index 100% rename from scripts/setup.sh rename to scripts/CI/setup.sh diff --git a/scripts/CI/test.sh b/scripts/CI/test.sh new file mode 100755 index 0000000..e42fe9e --- /dev/null +++ b/scripts/CI/test.sh @@ -0,0 +1,2 @@ +cd lockbox +pytest --cov=. --cov-report term-missing --reuse-db \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index 05819f3..0000000 --- a/scripts/test.sh +++ /dev/null @@ -1,2 +0,0 @@ -cd lockbox -pytest --cov=. --cov-report term-missing \ No newline at end of file