Skip to content

Commit

Permalink
Merge pull request #29 from nyu-devops/fix-db-create
Browse files Browse the repository at this point in the history
Fix db-create not working
  • Loading branch information
rofrano committed Feb 28, 2024
2 parents d940941 + af3babd commit 91420f2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- ..:/app
command: sleep infinity
environment:
FLASK_APP: service:app
FLASK_APP: wsgi:app
FLASK_DEBUG: "True"
GUNICORN_BIND: "0.0.0.0:8000"
DATABASE_URI: postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/postgres
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ test: ## Run the unit tests
$(info Running tests...)
pytest --disable-warnings

db-create: ## Creates the database tables
$(info Creating database tables...)
@flask db-create

##@ Runtime

run: ## Run the service
Expand Down
6 changes: 4 additions & 2 deletions tests/test_cli_commands.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""
CLI Command Extensions for Flask
"""

import os
from unittest import TestCase
from unittest.mock import patch, MagicMock
from click.testing import CliRunner

# pylint: disable=unused-import
from wsgi import app # noqa: F401
from service.common.cli_commands import db_create # noqa: E402
Expand All @@ -16,10 +18,10 @@ class TestFlaskCLI(TestCase):
def setUp(self):
self.runner = CliRunner()

@patch('service.common.cli_commands.db')
@patch("service.common.cli_commands.db")
def test_db_create(self, db_mock):
"""It should call the db-create command"""
db_mock.return_value = MagicMock()
with patch.dict(os.environ, {"FLASK_APP": "service:app"}, clear=True):
with patch.dict(os.environ, {"FLASK_APP": "wsgi:app"}, clear=True):
result = self.runner.invoke(db_create)
self.assertEqual(result.exit_code, 0)

0 comments on commit 91420f2

Please sign in to comment.