From bb0d6555cdc4e2613b5a6af80327d7343515a366 Mon Sep 17 00:00:00 2001 From: John Rofrano Date: Wed, 28 Feb 2024 16:18:16 +0000 Subject: [PATCH 1/2] Changed FLASK_APP to wsgi:app --- .devcontainer/docker-compose.yml | 2 +- tests/test_cli_commands.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 24570da..d1048a3 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -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 diff --git a/tests/test_cli_commands.py b/tests/test_cli_commands.py index 3729c3a..906e461 100644 --- a/tests/test_cli_commands.py +++ b/tests/test_cli_commands.py @@ -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 @@ -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) From af3babd5965db495cdb7ba47822d671df61948bf Mon Sep 17 00:00:00 2001 From: John Rofrano Date: Wed, 28 Feb 2024 16:24:14 +0000 Subject: [PATCH 2/2] added new db-create target --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 5273f06..95cdd2f 100644 --- a/Makefile +++ b/Makefile @@ -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