Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix db-create not working #29

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading