-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic logging and updated environment variables
- added github actions testing - updated enviroment variables in settings - added tests for logging files - updated setting to check for testing
- Loading branch information
1 parent
835f688
commit eae3c24
Showing
11 changed files
with
177 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SECRET_KEY='' | ||
DEBUG=True | ||
DB_HOST=db | ||
DB_PORT=5432 | ||
DB_NAME=term_db | ||
DB_USER=sadilar | ||
DB_PASSWORD=sadilar | ||
LOGGING_FILE=debug.log | ||
LOGGING_HANDLERS_LEVEL=INFO | ||
LOGGING_LOGGERS_LEVEL=INFO | ||
LOGGING_LOGGERS_DJANGO_LEVEL=INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SECRET_KEY='django-insecure-w!h85bp^$$e8gm%c23r!0%9i7yzd=6w$$s&ic+6!%306&kj8@k*5' | ||
DEBUG=True | ||
DB_HOST=db | ||
DB_PORT=5432 | ||
DB_NAME=term_db | ||
DB_USER=sadilar | ||
DB_PASSWORD=sadilar | ||
LOGGING_FILE=debug.log | ||
LOGGING_HANDLERS_LEVEL=INFO | ||
LOGGING_LOGGERS_LEVEL=INFO | ||
LOGGING_LOGGERS_DJANGO_LEVEL=INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Testing Django | ||
on: [ pull_request, push ] # activates the workflow when there is a push or pull request in the repo | ||
jobs: | ||
test_project: | ||
runs-on: ubuntu-latest # operating system your code will run on | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements-test.txt | ||
- name: Run linting tools | ||
run: | | ||
cd app/ | ||
ruff format . | ||
- name: Create logging folder | ||
run: | | ||
sudo mkdir -p /logging | ||
sudo chown runner:runner /logging | ||
- name: Run Tests | ||
run: | | ||
cp .env.testing app/.env | ||
cd app/ | ||
mkdir -p static_files | ||
python manage.py test | ||
- name: Manager Check | ||
run: | | ||
cd app/ | ||
python manage.py check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
import os | ||
import sys | ||
|
||
from django.test import TestCase | ||
|
||
|
||
class LoggingTest(TestCase): | ||
def setUp(self): | ||
LOGGING_FOLDER_DEFAULT = os.path.abspath(os.path.join("/logging/")) | ||
self.logger = logging.getLogger("django") | ||
self.log_file = os.path.join(LOGGING_FOLDER_DEFAULT, "debug.log") | ||
|
||
def test_log_file_created(self): | ||
"""Test if the log file is created.""" | ||
self.logger.error("This is a test error message.") | ||
|
||
self.assertTrue(os.path.exists(self.log_file)) | ||
|
||
def test_log_message(self): | ||
"""Test if the log message is written to the file.""" | ||
with open(self.log_file, "r") as f: | ||
content = f.read() | ||
self.assertIn("This is a test error message.", content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-r requirements.txt | ||
django-extensions | ||
ruff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
django==5.0.2 | ||
psycopg2-binary | ||
django-environ | ||
django-simple-history | ||
gunicorn | ||
psycopg2-binary | ||
whitenoise | ||
django-simple-history |