2018-04-09 22:09:58 +02:00
|
|
|
import os
|
|
|
|
|
2021-01-02 19:28:03 +01:00
|
|
|
from flask import Flask
|
|
|
|
|
2018-04-09 22:09:58 +02:00
|
|
|
|
2021-01-20 18:09:46 +01:00
|
|
|
class TestDevelopmentConfig:
|
|
|
|
def test_debug_is_enabled(self, app: Flask) -> None:
|
2020-09-16 15:41:02 +02:00
|
|
|
app.config.from_object('fittrackee.config.DevelopmentConfig')
|
2021-01-20 18:09:46 +01:00
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert app.config['DEBUG']
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
def test_testing_is_disabled(self, app: Flask) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.DevelopmentConfig')
|
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert not app.config['TESTING']
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
def test_sqlalchemy_is_configured_to_use_dev_database(
|
|
|
|
self, app: Flask
|
|
|
|
) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.DevelopmentConfig')
|
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert app.config['SQLALCHEMY_DATABASE_URI'] == os.environ.get(
|
|
|
|
'DATABASE_URL'
|
|
|
|
)
|
2018-04-09 22:09:58 +02:00
|
|
|
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
class TestTestingConfig:
|
|
|
|
def test_debug_is_enabled(self, app: Flask) -> None:
|
2020-09-16 15:41:02 +02:00
|
|
|
app.config.from_object('fittrackee.config.TestingConfig')
|
2021-01-20 18:09:46 +01:00
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert app.config['DEBUG']
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
def test_testing_is_enabled(self, app: Flask) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.TestingConfig')
|
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert app.config['TESTING']
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
def test_sqlalchemy_is_configured_to_use_testing_database(
|
|
|
|
self, app: Flask
|
|
|
|
) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.TestingConfig')
|
|
|
|
|
|
|
|
assert app.config['SQLALCHEMY_DATABASE_URI'] == os.environ.get(
|
|
|
|
'DATABASE_TEST_URL'
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_it_does_not_preserve_context_on_exception(
|
|
|
|
self, app: Flask
|
|
|
|
) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.TestingConfig')
|
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert not app.config['PRESERVE_CONTEXT_ON_EXCEPTION']
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestProductionConfig:
|
|
|
|
def test_debug_is_disabled(self, app: Flask) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.ProductionConfig')
|
|
|
|
|
|
|
|
assert not app.config['DEBUG']
|
|
|
|
|
|
|
|
def test_testing_is_disabled(self, app: Flask) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.ProductionConfig')
|
|
|
|
|
|
|
|
assert not app.config['TESTING']
|
|
|
|
|
|
|
|
def test_sqlalchemy_is_configured_to_use_testing_database(
|
|
|
|
self, app: Flask
|
|
|
|
) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.ProductionConfig')
|
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
assert app.config['SQLALCHEMY_DATABASE_URI'] == os.environ.get(
|
|
|
|
'DATABASE_TEST_URL'
|
|
|
|
)
|
2021-01-20 18:09:46 +01:00
|
|
|
|
|
|
|
def test_it_does_not_preserve_context_on_exception(
|
|
|
|
self, app: Flask
|
|
|
|
) -> None:
|
|
|
|
app.config.from_object('fittrackee.config.ProductionConfig')
|
|
|
|
|
|
|
|
assert not app.config['PRESERVE_CONTEXT_ON_EXCEPTION']
|