Skip to content

Commit

Permalink
Issue #112 replace (test related) flask_error_handling config with cr…
Browse files Browse the repository at this point in the history
…eate_app option
  • Loading branch information
soxofaan committed Feb 7, 2024
1 parent 0615689 commit aae2338
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/openeo_aggregator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_log = logging.getLogger(__name__)


def create_app(config: Any = None, auto_logging_setup: bool = True) -> flask.Flask:
def create_app(config: Any = None, auto_logging_setup: bool = True, flask_error_handling: bool = True) -> flask.Flask:
"""
Flask application factory function.
"""
Expand All @@ -54,7 +54,7 @@ def create_app(config: Any = None, auto_logging_setup: bool = True) -> flask.Fla
_log.info(f"Building Flask app with {backend_implementation=!r}")
app = openeo_driver.views.build_app(
backend_implementation=backend_implementation,
error_handling=config.flask_error_handling,
error_handling=flask_error_handling,
)

app.config.from_mapping(
Expand Down
1 change: 0 additions & 1 deletion src/openeo_aggregator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class AggregatorConfig(dict):
# Dictionary mapping backend id to backend url
aggregator_backends = dict_item()

flask_error_handling = dict_item(default=True)
streaming_chunk_size = dict_item(default=STREAM_CHUNK_SIZE_DEFAULT)

# TODO: add validation/normalization to make sure we have a real list of OidcProvider objects?
Expand Down
10 changes: 7 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,13 @@ def multi_backend_connection(config) -> MultiBackendConnection:


def get_flask_app(config: AggregatorConfig) -> flask.Flask:
app = create_app(config=config, auto_logging_setup=False)
app.config['TESTING'] = True
app.config['SERVER_NAME'] = 'oeoa.test'
app = create_app(
config=config,
auto_logging_setup=False,
# flask_error_handling=False, # Failing test debug tip: set to False for deeper stack trace insights
)
app.config["TESTING"] = True
app.config["SERVER_NAME"] = "oeoa.test"
return app


Expand Down
1 change: 0 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_config_defaults():
config = AggregatorConfig()
with pytest.raises(KeyError):
_ = config.aggregator_backends
assert config.flask_error_handling is True
assert config.streaming_chunk_size == STREAM_CHUNK_SIZE_DEFAULT


Expand Down

0 comments on commit aae2338

Please sign in to comment.