From aea0e4e14c1f08b39e6e995c790d5ff0a6337625 Mon Sep 17 00:00:00 2001 From: Anshul Agrawal Date: Sun, 12 Jan 2025 12:20:19 +0530 Subject: [PATCH] Fix the failing test --- mslib/mswms/mswms.py | 3 +-- mslib/mswms/wms.py | 3 ++- tests/_test_mswms/pytest.log | 4 ++++ tests/_test_mswms/test_mswms.py | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 tests/_test_mswms/pytest.log diff --git a/mslib/mswms/mswms.py b/mslib/mswms/mswms.py index 0852ec4bc..34e8cde59 100644 --- a/mslib/mswms/mswms.py +++ b/mslib/mswms/mswms.py @@ -31,7 +31,7 @@ from mslib import __version__ from mslib.utils import setup_logging, LOGGER - +from mslib.mswms.wms import app as application def main(): parser = argparse.ArgumentParser() @@ -88,7 +88,6 @@ def main(): # keep the import after the version check. This creates all layers. from mslib.mswms.wms import mswms_settings, server - from mslib.mswms.wms import app as application if args.action == "gallery": if args.plot_types is None: diff --git a/mslib/mswms/wms.py b/mslib/mswms/wms.py index 7f9887ce8..06b79e814 100644 --- a/mslib/mswms/wms.py +++ b/mslib/mswms/wms.py @@ -65,7 +65,7 @@ from mslib.index import create_app from mslib.mswms.gallery_builder import add_image, write_html, add_levels, add_times, \ write_doc_index, write_code_pages, STATIC_LOCATION, DOCS_LOCATION -from mslib.utils import LOGGER +from mslib.utils import LOGGER, setup_logging # Flask basic auth's documentation # https://flask-basicauth.readthedocs.io/en/latest/#flask.ext.basicauth.BasicAuth.check_credentials @@ -100,6 +100,7 @@ class default_mswms_settings: mswms_settings = default_mswms_settings() +setup_logging() try: import mswms_settings as user_settings diff --git a/tests/_test_mswms/pytest.log b/tests/_test_mswms/pytest.log new file mode 100644 index 000000000..336dac71d --- /dev/null +++ b/tests/_test_mswms/pytest.log @@ -0,0 +1,4 @@ +2025-01-12 12:08:42 DEBUG FuncMMsH_pM3BxH0AAAB +2025-01-12 12:08:42 DEBUG Handling disconnect. +2025-01-12 12:08:42 DEBUG Disconnected: FuncMMsH_pM3BxH0AAAB +2025-01-12 12:08:42 DEBUG No user settings found, using default settings diff --git a/tests/_test_mswms/test_mswms.py b/tests/_test_mswms/test_mswms.py index 971ddc78e..809e68136 100644 --- a/tests/_test_mswms/test_mswms.py +++ b/tests/_test_mswms/test_mswms.py @@ -29,6 +29,7 @@ import mock import argparse import pytest +import logging from mslib.mswms import mswms @@ -49,7 +50,7 @@ def test_main(): with mock.patch("mslib.mswms.mswms.argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(plot_types=None, version=False, update=False, gallery=False, - debug=False, logfile=None, action=None, + loglevel=logging.INFO, logfile=None, action=None, host=None, port=None)): mswms.main() assert pytest_wrapped_e.typename == "SystemExit"