Merge pull request #19 from pamelafox/testing-setup
Browse files- .devcontainer/devcontainer.json +0 -2
- .env.sample +3 -0
- .env.test +3 -0
- .github/workflows/check.yaml +1 -1
- .vscode/settings.json +0 -11
- infra/main.bicep +1 -0
- pyproject.toml +2 -1
- requirements-dev.txt +1 -0
- src/quizsite/settings.py +2 -1
.devcontainer/devcontainer.json
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
2 |
-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
|
3 |
{
|
4 |
"name": "django-quiz-app",
|
5 |
"dockerComposeFile": "docker-compose.yml",
|
|
|
|
|
|
|
1 |
{
|
2 |
"name": "django-quiz-app",
|
3 |
"dockerComposeFile": "docker-compose.yml",
|
.env.sample
CHANGED
@@ -2,4 +2,7 @@ DBHOST=localhost
|
|
2 |
DBNAME=app
|
3 |
DBUSER=app_user
|
4 |
DBPASS=app_password
|
|
|
5 |
SECRET_KEY=InsecureKeyNotForProduction
|
|
|
|
|
|
2 |
DBNAME=app
|
3 |
DBUSER=app_user
|
4 |
DBPASS=app_password
|
5 |
+
DEBUG=True
|
6 |
SECRET_KEY=InsecureKeyNotForProduction
|
7 |
+
STATIC_BACKEND=whitenoise.storage.CompressedManifestStaticFilesStorage
|
8 |
+
DJANGO_SETTINGS_MODULE=quizsite.settings
|
.env.test
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# This file is checked in, so it should NOT contain keys or secrets
|
2 |
+
STATIC_BACKEND=django.contrib.staticfiles.storage.StaticFilesStorage
|
3 |
+
DJANGO_SETTINGS_MODULE=quizsite.settings
|
.github/workflows/check.yaml
CHANGED
@@ -39,7 +39,7 @@ jobs:
|
|
39 |
DBPASS: postgres
|
40 |
SECRET_KEY: django-insecure-key-${{ github.run_id }}-${{ github.run_attempt }}
|
41 |
run: |
|
42 |
-
|
43 |
python3 -m pytest | tee pytest-coverage.txt
|
44 |
- name: Pytest coverage comment
|
45 |
uses: MishaKav/pytest-coverage-comment@main
|
|
|
39 |
DBPASS: postgres
|
40 |
SECRET_KEY: django-insecure-key-${{ github.run_id }}-${{ github.run_attempt }}
|
41 |
run: |
|
42 |
+
set -o pipefail
|
43 |
python3 -m pytest | tee pytest-coverage.txt
|
44 |
- name: Pytest coverage comment
|
45 |
uses: MishaKav/pytest-coverage-comment@main
|
.vscode/settings.json
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"python.testing.unittestArgs": [
|
3 |
-
"-v",
|
4 |
-
"-s",
|
5 |
-
"./src",
|
6 |
-
"-p",
|
7 |
-
"test*.py"
|
8 |
-
],
|
9 |
-
"python.testing.pytestEnabled": false,
|
10 |
-
"python.testing.unittestEnabled": true
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
infra/main.bicep
CHANGED
@@ -79,6 +79,7 @@ module web 'core/host/appservice.bicep' = {
|
|
79 |
DBUSER: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=postgresAdminUser)'
|
80 |
DBPASS: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=postgresAdminPassword)'
|
81 |
DBSSL: 'require'
|
|
|
82 |
SECRET_KEY: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=djangoSecretKey)'
|
83 |
}
|
84 |
}
|
|
|
79 |
DBUSER: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=postgresAdminUser)'
|
80 |
DBPASS: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=postgresAdminPassword)'
|
81 |
DBSSL: 'require'
|
82 |
+
STATIC_BACKEND: 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
83 |
SECRET_KEY: '@Microsoft.KeyVault(VaultName=${keyVault.outputs.name};SecretName=djangoSecretKey)'
|
84 |
}
|
85 |
}
|
pyproject.toml
CHANGED
@@ -17,4 +17,5 @@ exclude = '''
|
|
17 |
addopts = "-ra --cov=src --cov-report=term-missing:skip-covered --junitxml=pytest.xml"
|
18 |
pythonpath = ["src"]
|
19 |
python_files = ["tests.py"]
|
20 |
-
|
|
|
|
17 |
addopts = "-ra --cov=src --cov-report=term-missing:skip-covered --junitxml=pytest.xml"
|
18 |
pythonpath = ["src"]
|
19 |
python_files = ["tests.py"]
|
20 |
+
env_override_existing_values = 1
|
21 |
+
env_files = [".env", ".env.test"]
|
requirements-dev.txt
CHANGED
@@ -5,3 +5,4 @@ ruff
|
|
5 |
coverage
|
6 |
pytest-django
|
7 |
pytest-cov
|
|
|
|
5 |
coverage
|
6 |
pytest-django
|
7 |
pytest-cov
|
8 |
+
pytest-dotenv
|
src/quizsite/settings.py
CHANGED
@@ -21,6 +21,7 @@ env = environ.Env(
|
|
21 |
DBENGINE=(str, "django.db.backends.postgresql_psycopg2"),
|
22 |
DBSSL=(str, "disable"),
|
23 |
ADMIN_URL=(str, "admin/"),
|
|
|
24 |
)
|
25 |
|
26 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
@@ -154,7 +155,7 @@ STATIC_URL = "static/"
|
|
154 |
# https://whitenoise.evans.io/en/stable/django.html
|
155 |
STORAGES = {
|
156 |
"staticfiles": {
|
157 |
-
"BACKEND": "
|
158 |
},
|
159 |
}
|
160 |
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
|
|
21 |
DBENGINE=(str, "django.db.backends.postgresql_psycopg2"),
|
22 |
DBSSL=(str, "disable"),
|
23 |
ADMIN_URL=(str, "admin/"),
|
24 |
+
STATIC_BACKEND=(str, "django.contrib.staticfiles.storage.StaticFilesStorage"),
|
25 |
)
|
26 |
|
27 |
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
155 |
# https://whitenoise.evans.io/en/stable/django.html
|
156 |
STORAGES = {
|
157 |
"staticfiles": {
|
158 |
+
"BACKEND": env("STATIC_BACKEND"),
|
159 |
},
|
160 |
}
|
161 |
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|