Skip to content

Commit

Permalink
fix(ci): add FLASK_ENV for each environment
Browse files Browse the repository at this point in the history
  • Loading branch information
richardnguyen99 committed Dec 28, 2023
1 parent 6a746fc commit b1e6c09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cursus/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class DevConfig(Config):
CSRF_ENABLED = True
LOG_LEVEL = "DEBUG"
DATABASE_URL = os.environ.get("DATABASE_URL")
FLASK_ENV = "development"


class ProdConfig(Config):
Expand All @@ -125,6 +126,7 @@ class ProdConfig(Config):

DEBUG = False
LOG_LEVEL = "INFO"
FLASK_ENV = "production"
PREFERRED_URL_SCHEME = "https"
DATABASE_URL = os.environ.get("DATABASE_URL")

Expand All @@ -143,3 +145,4 @@ class TestingConfig(Config):
SWAGGER_API_SPEC_URL = ""
DATABASE_URL = os.environ.get("TEST_DATABASE_URL")
SQLALCHEMY_DATABASE_URI = os.environ.get("TEST_DATABASE_URL")
FLASK_ENV = "testing"
4 changes: 4 additions & 0 deletions test/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ def test_config():
load_dotenv(env_file, override=True)

assets._named_bundles = {} # pylint: disable=protected-access
os.environ["APP_SETTINGS"] = "cursus.config.DevConfig"
app = create_app()

assert not app.config["TESTING"]
assert app.config["FLASK_ENV"] == "development"
assert app.config["DATABASE_URL"] == os.environ.get("DATABASE_URL")

assets._named_bundles = {} # pylint: disable=protected-access
app = create_app("cursus.config.TestingConfig")

assert app.config["TESTING"]
assert app.config["FLASK_ENV"] == "testing"
assert app.config["DATABASE_URL"] == os.environ.get("TEST_DATABASE_URL")


Expand Down

0 comments on commit b1e6c09

Please sign in to comment.