Skip to content

Commit

Permalink
Adds config to run locally without docker in a VSCode context
Browse files Browse the repository at this point in the history
Running the app locally without docker allows better debugging and avoiding docker-related issues.

Closes #84.
  • Loading branch information
afred committed Nov 1, 2023
1 parent 57a87ae commit 7569204
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"python": "${workspaceFolder}/venv/bin/python",
"args": [
"runserver",
"0.0.0.0:8001"
],
"django": true,
"justMyCode": false
},
{
"name": "Python: Django Migrations",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"python": "${workspaceFolder}/venv/bin/python",
"args": [
"migrate",
"--noinput"
],
"django": true,
"justMyCode": false
},
{
"name": "Python: Django Tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"python": "${workspaceFolder}/venv/bin/python",
"args": [
"test",
],
"django": true,
"justMyCode": false
},
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./ov_wag",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ services:
- ./db:/var/lib/postgresql/data:Z
user: ${UID}:${GID}
restart: always
ports:
- 5432:5432
environment:
- POSTGRES_DB=${OV_DB_NAME}
- POSTGRES_USER=${OV_DB_USER}
- POSTGRES_PASSWORD=${OV_DB_PASSWORD}
5 changes: 5 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import os
import sys

from dotenv import load_dotenv

# take environment variables from .env.
load_dotenv()

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ov_wag.settings.dev")

Expand Down
8 changes: 5 additions & 3 deletions ov_wag/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def test_exhibit_api_schema_single(self):
Compare response against ExhibitSchema
"""
exhibit_page = ExhibitPageFactory.create(parent=self.__home_page())
response = self.client.get(f'/api/v2/exhibits/{exhibit_page.id}/', format='json')
response = self.client.get(
f'/api/v2/exhibits/{exhibit_page.id}/', format='json'
)
json = response.json()
self.assertValidSchema(json)

Expand All @@ -51,8 +53,8 @@ def test_exhibit_api_schema_multiple(self):
Compare response against ExhibitSchema
"""
exhibit_page = ExhibitPageFactory.create(parent=self.__home_page())
response = self.client.get(f'/api/v2/exhibits/', format='json')
ExhibitPageFactory.create(parent=self.__home_page())
response = self.client.get('/api/v2/exhibits/', format='json')
json = response.json()
for item in json['items']:
self.assertValidSchema(item)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ wagtail >= 4.0.4, < 4.1
wagtail_factories >= 3.1.0, < 3.2
pydantic >= 1.10.2, < 2.0
psycopg2 >= 2.9.3, < 2.10
python-dotenv >= 1.0.0, < 2.0

0 comments on commit 7569204

Please sign in to comment.