• Bug#1061042: flask-mongoengine: FTBFS: tests failed (1/2)

    From Lucas Nussbaum@21:1/5 to All on Tue Jan 16 21:00:12 2024
    Source: flask-mongoengine
    Version: 1.0.0-1
    Severity: serious
    Justification: FTBFS
    Tags: trixie sid ftbfs
    User: lucas@debian.org
    Usertags: ftbfs-20240115 ftbfs-trixie

    Hi,

    During a rebuild of all packages in sid, your package failed to build
    on amd64.


    Relevant part (hopefully):
    debian/rules build
    dh build --with python3 --buildsystem=pybuild
    dh_update_autotools_config -O--buildsystem=pybuild
    dh_autoreconf -O--buildsystem=pybuild
    dh_auto_configure -O--buildsystem=pybuild
    I: pybuild base:305: python3.12 setup.py config
    running config
    I: pybuild base:305: python3.11 setup.py config
    running config
    dh_auto_build -O--buildsystem=pybuild
    I: pybuild base:305: /usr/bin/python3.12 setup.py build
    running build
    running build_py
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/operation_tracker.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/__init__.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/json.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/pagination.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/panels.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/sessions.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/connection.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/__init__.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/models.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/fields.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/base.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/orm.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/wtf
    running egg_info
    creating flask_mongoengine.egg-info
    writing flask_mongoengine.egg-info/PKG-INFO
    writing dependency_links to flask_mongoengine.egg-info/dependency_links.txt writing requirements to flask_mongoengine.egg-info/requires.txt
    writing top-level names to flask_mongoengine.egg-info/top_level.txt
    writing manifest file 'flask_mongoengine.egg-info/SOURCES.txt'
    reading manifest file 'flask_mongoengine.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
    adding license file 'LICENSE'
    adding license file 'AUTHORS'
    writing manifest file 'flask_mongoengine.egg-info/SOURCES.txt' /usr/lib/python3/dist-packages/setuptools/command/build_py.py:204: _Warning: Package 'flask_mongoengine.templates.panels' is absent from the `packages` configuration.
    !!

    ********************************************************************************
    ############################
    # Package would be ignored #
    ############################
    Python recognizes 'flask_mongoengine.templates.panels' as an importable package[^1],
    but it is absent from setuptools' `packages` configuration.

    This leads to an ambiguous overall configuration. If you want to distribute this
    package, please make sure that 'flask_mongoengine.templates.panels' is explicitly added
    to the `packages` configuration field.

    Alternatively, you can also rely on setuptools' discovery methods
    (for example by using `find_namespace_packages(...)`/`find_namespace:`
    instead of `find_packages(...)`/`find:`).

    You can read more about "package discovery" on setuptools documentation page:

    - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

    If you don't want 'flask_mongoengine.templates.panels' to be distributed and are
    already explicitly excluding 'flask_mongoengine.templates.panels' via
    `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
    you can try to use `exclude_package_data`, or `include-package-data=False` in
    combination with a more fine grained `package-data` configuration.

    You can read more about "package data files" on setuptools documentation page:

    - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


    [^1]: For Python, any directory (with suitable naming) can be imported,
    even if it does not contain any `.py` files.
    On the other hand, currently there is no concept of package data
    directory, all directories are treated like packages.
    ********************************************************************************

    !!
    check.warn(importable)
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/templates
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/templates/panels
    copying flask_mongoengine/templates/panels/mongo-panel.html -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build/flask_mongoengine/templates/panels
    I: pybuild base:305: /usr/bin/python3 setup.py build
    running build
    running build_py
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/operation_tracker.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/__init__.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/json.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/pagination.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/panels.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/sessions.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    copying flask_mongoengine/connection.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/__init__.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/models.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/fields.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/base.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    copying flask_mongoengine/wtf/orm.py -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/wtf
    running egg_info
    writing flask_mongoengine.egg-info/PKG-INFO
    writing dependency_links to flask_mongoengine.egg-info/dependency_links.txt writing requirements to flask_mongoengine.egg-info/requires.txt
    writing top-level names to flask_mongoengine.egg-info/top_level.txt
    reading manifest file 'flask_mongoengine.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
    adding license file 'LICENSE'
    adding license file 'AUTHORS'
    writing manifest file 'flask_mongoengine.egg-info/SOURCES.txt' /usr/lib/python3/dist-packages/setuptools/command/build_py.py:204: _Warning: Package 'flask_mongoengine.templates.panels' is absent from the `packages` configuration.
    !!

    ********************************************************************************
    ############################
    # Package would be ignored #
    ############################
    Python recognizes 'flask_mongoengine.templates.panels' as an importable package[^1],
    but it is absent from setuptools' `packages` configuration.

    This leads to an ambiguous overall configuration. If you want to distribute this
    package, please make sure that 'flask_mongoengine.templates.panels' is explicitly added
    to the `packages` configuration field.

    Alternatively, you can also rely on setuptools' discovery methods
    (for example by using `find_namespace_packages(...)`/`find_namespace:`
    instead of `find_packages(...)`/`find:`).

    You can read more about "package discovery" on setuptools documentation page:

    - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

    If you don't want 'flask_mongoengine.templates.panels' to be distributed and are
    already explicitly excluding 'flask_mongoengine.templates.panels' via
    `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
    you can try to use `exclude_package_data`, or `include-package-data=False` in
    combination with a more fine grained `package-data` configuration.

    You can read more about "package data files" on setuptools documentation page:

    - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


    [^1]: For Python, any directory (with suitable naming) can be imported,
    even if it does not contain any `.py` files.
    On the other hand, currently there is no concept of package data
    directory, all directories are treated like packages.
    ********************************************************************************

    !!
    check.warn(importable)
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/templates
    creating /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/templates/panels
    copying flask_mongoengine/templates/panels/mongo-panel.html -> /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_flask-mongoengine/build/flask_mongoengine/templates/panels
    dh_auto_test -O--buildsystem=pybuild
    I: pybuild base:305: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_flask-mongoengine/build; python3.12 -m pytest --override-ini=addopts=--verbose tests/test_base.py tests/test_connection.py -k 'not test_multiple_connections'
    ============================= test session starts ==============================
    platform linux -- Python 3.12.1, pytest-7.4.4, pluggy-1.3.0 -- /usr/bin/python3.12
    cachedir: .pytest_cache
    rootdir: /<<PKGBUILDDIR>>
    configfile: setup.cfg
    collecting ... collected 17 items / 1 deselected / 16 selected

    tests/test_base.py::test_mongoengine_class__should_raise_type_error__if_config_not_dict PASSED [ 6%]
    tests/test_base.py::test_init_app__should_raise_type_error__if_config_not_dict[None] PASSED [ 12%]
    tests/test_base.py::test_init_app__should_raise_type_error__if_config_not_dict[Not dict type] PASSED [ 18%]
    tests/test_connection.py::test_connection__should_use_defaults__if_no_settings_provided PASSED [ 25%]
    tests/test_connection.py::test_connection__should_pass_alias__if_provided[Dict format] PASSED [ 31%]
    tests/test_connection.py::test_connection__should_pass_alias__if_provided[Config variable format] PASSED [ 37%]
    tests/test_connection.py::test_connection__should_parse_host_uri__if_host_formatted_as_uri[Dict format] PASSED [ 43%]
    tests/test_connection.py::test_connection__should_parse_host_uri__if_host_formatted_as_uri[Config variable format] PASSED [ 50%]
    tests/test_connection.py::test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Dict format as URI] FAILED [ 56%]
    tests/test_connection.py::test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Dict format as Param] FAILED [ 62%]
    tests/test_connection.py::test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Config variable format as URI] FAILED [ 68%]
    tests/test_connection.py::test_connection__should_raise__if_uri_not_properly_formatted[Dict format as URI] PASSED [ 75%]
    tests/test_connection.py::test_connection__should_raise__if_uri_not_properly_formatted[Config variable format as URI] PASSED [ 81%]
    tests/test_connection.py::test_connection__should_accept_host_as_list PASSED [ 87%]
    tests/test_connection.py::test_ingnored_mongodb_prefix_config PASSED [ 93%]
    tests/test_connection.py::test_connection_kwargs PASSED [100%]

    =================================== FAILURES ===================================
    _ test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Dict format as URI] _

    app = <Flask 'tests.conftest'>
    config_extension = {'MONGODB_SETTINGS': {'HOST': 'mongomock://localhost:27017/flask_mongoengine_test_db'}}

    @pytest.mark.parametrize(
    ("config_extension"),
    [
    {
    "MONGODB_SETTINGS": {
    "HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"
    }
    },
    {
    "MONGODB_SETTINGS": {
    "ALIAS": "simple_conn",
    "HOST": "localhost",
    "PORT": 27017,
    "DB": "flask_mongoengine_test_db",
    "IS_MOCK": True,
    }
    },
    {"MONGODB_HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"},
    ],
    ids=("Dict format as URI", "Dict format as Param", "Config variable format as URI"),
    )
    def test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings(
    app, config_extension
    ):
    """Make sure a simple connection pass ALIAS setting variable."""
    db = MongoEngine()
    app.config.update(config_extension)

    # Verify no extension for Mongoengine yet created for app
    assert app.extensions == {}
    assert current_mongoengine_instance() is None

    # Create db connection. Should return None.

    with pytest.raises(RuntimeError) as error:
    assert db.init_app(app) is None

    tests/test_connection.py:167:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    flask_mongoengine/__init__.py:132: in init_app
    connections = create_connections(config) flask_mongoengine/connection.py:140: in create_connections
    return _connect(conn_settings)
    flask_mongoengine/connection.py:148: in _connect
    return mongoengine.connect(db_name, **conn_settings) /usr/lib/python3/dist-packages/mongoengine/connection.py:436: in connect
    register_connection(alias, db, **kwargs) /usr/lib/python3/dist-packages/mongoengine/connection.py:224: in register_connection
    conn_settings = _get_connection_settings(
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    db = 'flask_mongoengine_test_db', name = None
    host = 'mongomock://localhost:27017/flask_mongoengine_test_db', port = 27017 read_preference = Primary(), username = None, password = None authentication_source = None, authentication_mechanism = None authmechanismproperties = None, kwargs = {}
    conn_settings = {'authentication_mechanism': None, 'authentication_source': None, 'authmechanismproperties': None, 'host': 'mongomock://localhost:27017/flask_mongoengine_test_db', ...}
    conn_host = ['mongomock://localhost:27017/flask_mongoengine_test_db'] resolved_hosts = []
    entity = 'mongomock://localhost:27017/flask_mongoengine_test_db'

    def _get_connection_settings(
    db=None,
    name=None,
    host=None,
    port=None,
    read_preference=READ_PREFERENCE,
    username=None,
    password=None,
    authentication_source=None,
    authentication_mechanism=None,
    authmechanismproperties=None,
    **kwargs,
    ):
    """Get the connection settings as a dict

    :param db: the name of the database to use, for compatibility with connect
    :param name: the name of the specific database to use
    :param host: the host name of the: program: `mongod` instance to connect to
    :param port: the port that the: program: `mongod` instance is running on
    :param read_preference: The read preference for the collection
    :param username: username to authenticate with
    :param password: password to authenticate with
    :param authentication_source: database to authenticate against
    :param authentication_mechanism: database authentication mechanisms.
    By default, use SCRAM-SHA-1 with MongoDB 3.0 and later,
    MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
    :param mongo_client_class: using alternative connection client other than
    pymongo.MongoClient, e.g. mongomock, montydb, that provides pymongo alike
    interface but not necessarily for connecting to a real mongo instance.
    :param kwargs: ad-hoc parameters to be passed into the pymongo driver,
    for example maxpoolsize, tz_aware, etc. See the documentation
    for pymongo's `MongoClient` for a full list.
    """
    conn_settings = {
    "name": name or db or DEFAULT_DATABASE_NAME,
    "host": host or DEFAULT_HOST,
    "port": port or DEFAULT_PORT,
    "read_preference": read_preference,
    "username": username,
    "password": password,
    "authentication_source": authentication_source,
    "authentication_mechanism": authentication_mechanism,
    "authmechanismproperties": authmechanismproperties,
    }

    _check_db_name(conn_settings["name"])
    conn_host = conn_settings["host"]

    # Host can be a list or a string, so if string, force to a list.
    if isinstance(conn_host, str):
    conn_host = [conn_host]

    resolved_hosts = []
    for entity in conn_host:
    # Reject old mongomock integration
    # To be removed in a few versions after 0.27.0
    if entity.startswith("mongomock://") or kwargs.get("is_mock"):
    raise Exception(
    "Use of mongomock:// URI or 'is_mock' were removed in favor of 'mongo_client_class=mongomock.MongoClient'. "
    "Check the CHANGELOG for more info"
    )
    E Exception: Use of mongomock:// URI or 'is_mock' were removed in favor of 'mongo_client_class=mongomock.MongoClient'. Check the CHANGELOG for more info

    /usr/lib/python3/dist-packages/mongoengine/connection.py:108: Exception
    _ test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Dict format as Param] _

    app = <Flask 'tests.conftest'>
    config_extension = {'MONGODB_SETTINGS': {'ALIAS': 'simple_conn', 'DB': 'flask_mongoengine_test_db', 'HOST': 'localhost', 'IS_MOCK': True, ...}}

    @pytest.mark.parametrize(
    ("config_extension"),
    [
    {
    "MONGODB_SETTINGS": {
    "HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"
    }
    },
    {
    "MONGODB_SETTINGS": {
    "ALIAS": "simple_conn",
    "HOST": "localhost",
    "PORT": 27017,
    "DB": "flask_mongoengine_test_db",
    "IS_MOCK": True,
    }
    },
    {"MONGODB_HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"},
    ],
    ids=("Dict format as URI", "Dict format as Param", "Config variable format as URI"),
    )
    def test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings(
    app, config_extension
    ):
    """Make sure a simple connection pass ALIAS setting variable."""
    db = MongoEngine()
    app.config.update(config_extension)

    # Verify no extension for Mongoengine yet created for app
    assert app.extensions == {}
    assert current_mongoengine_instance() is None

    # Create db connection. Should return None.

    with pytest.raises(RuntimeError) as error:
    assert db.init_app(app) is None

    tests/test_connection.py:167:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    flask_mongoengine/__init__.py:132: in init_app
    connections = create_connections(config) flask_mongoengine/connection.py:140: in create_connections
    return _connect(conn_settings)
    flask_mongoengine/connection.py:148: in _connect
    return mongoengine.connect(db_name, **conn_settings) /usr/lib/python3/dist-packages/mongoengine/connection.py:436: in connect
    register_connection(alias, db, **kwargs) /usr/lib/python3/dist-packages/mongoengine/connection.py:224: in register_connection
    conn_settings = _get_connection_settings(
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    db = 'flask_mongoengine_test_db', name = None, host = 'localhost', port = 27017
    read_preference = Primary(), username = None, password = None authentication_source = None, authentication_mechanism = None authmechanismproperties = None, kwargs = {'is_mock': True}
    conn_settings = {'authentication_mechanism': None, 'authentication_source': None, 'authmechanismproperties': None, 'host': 'localhost', ...}
    conn_host = ['localhost'], resolved_hosts = [], entity = 'localhost'

    def _get_connection_settings(
    db=None,
    name=None,
    host=None,
    port=None,
    read_preference=READ_PREFERENCE,
    username=None,
    password=None,
    authentication_source=None,
    authentication_mechanism=None,
    authmechanismproperties=None,
    **kwargs,
    ):
    """Get the connection settings as a dict

    :param db: the name of the database to use, for compatibility with connect
    :param name: the name of the specific database to use
    :param host: the host name of the: program: `mongod` instance to connect to
    :param port: the port that the: program: `mongod` instance is running on
    :param read_preference: The read preference for the collection
    :param username: username to authenticate with
    :param password: password to authenticate with
    :param authentication_source: database to authenticate against
    :param authentication_mechanism: database authentication mechanisms.
    By default, use SCRAM-SHA-1 with MongoDB 3.0 and later,
    MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
    :param mongo_client_class: using alternative connection client other than
    pymongo.MongoClient, e.g. mongomock, montydb, that provides pymongo alike
    interface but not necessarily for connecting to a real mongo instance.
    :param kwargs: ad-hoc parameters to be passed into the pymongo driver,
    for example maxpoolsize, tz_aware, etc. See the documentation
    for pymongo's `MongoClient` for a full list.
    """
    conn_settings = {
    "name": name or db or DEFAULT_DATABASE_NAME,
    "host": host or DEFAULT_HOST,
    "port": port or DEFAULT_PORT,
    "read_preference": read_preference,
    "username": username,
    "password": password,
    "authentication_source": authentication_source,
    "authentication_mechanism": authentication_mechanism,
    "authmechanismproperties": authmechanismproperties,
    }

    _check_db_name(conn_settings["name"])
    conn_host = conn_settings["host"]

    # Host can be a list or a string, so if string, force to a list.
    if isinstance(conn_host, str):
    conn_host = [conn_host]

    resolved_hosts = []
    for entity in conn_host:
    # Reject old mongomock integration
    # To be removed in a few versions after 0.27.0
    if entity.startswith("mongomock://") or kwargs.get("is_mock"):
    raise Exception(
    "Use of mongomock:// URI or 'is_mock' were removed in favor of 'mongo_client_class=mongomock.MongoClient'. "
    "Check the CHANGELOG for more info"
    )
    E Exception: Use of mongomock:// URI or 'is_mock' were removed in favor of 'mongo_client_class=mongomock.MongoClient'. Check the CHANGELOG for more info

    /usr/lib/python3/dist-packages/mongoengine/connection.py:108: Exception
    _ test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings[Config variable format as URI] _

    app = <Flask 'tests.conftest'>
    config_extension = {'MONGODB_HOST': 'mongomock://localhost:27017/flask_mongoengine_test_db'}

    @pytest.mark.parametrize(
    ("config_extension"),
    [
    {
    "MONGODB_SETTINGS": {
    "HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"
    }
    },
    {
    "MONGODB_SETTINGS": {
    "ALIAS": "simple_conn",
    "HOST": "localhost",
    "PORT": 27017,
    "DB": "flask_mongoengine_test_db",
    "IS_MOCK": True,
    }
    },
    {"MONGODB_HOST": "mongomock://localhost:27017/flask_mongoengine_test_db"},
    ],
    ids=("Dict format as URI", "Dict format as Param", "Config variable format as URI"),
    )
    def test_connection__should_parse_mongo_mock_uri__as_uri_and_as_settings(
    app, config_extension
    ):
    """Make sure a simple connection pass ALIAS setting variable."""
    db = MongoEngine()
    app.config.update(config_extension)

    # Verify no extension for Mongoengine yet created for app
    assert app.extensions == {}
    assert current_mongoengine_instance() is None

    # Create db connection. Should return None.

    with pytest.raises(RuntimeError) as error:
    assert db.init_app(app) is None

    tests/test_connection.py:167:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    flask_mongoengine/__init__.py:132: in init_app
    connections = create_connections(config) flask_mongoengine/connection.py:140: in create_connections
    return _connect(conn_settings)
    flask_mongoengine/connection.py:148: in _connect
    return mongoengine.connect(db_name, **conn_settings) /usr/lib/python3/dist-packages/mongoengine/connection.py:436: in connect
    register_connection(alias, db, **kwargs) /usr/lib/python3/dist-packages/mongoengine/connection.py:224: in register_connection
    conn_settings = _get_connection_settings(
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    db = 'flask_mongoengine_test_db', name = None
    host = 'mongomock://localhost:27017/flask_mongoengine_test_db', port = 27017 read_preference = Primary(), username = None, password = None authentication_source = None, authentication_mechanism = None authmechanismproperties = None, kwargs = {}
    conn_settings = {'authentication_mechanism': None, 'authentication_source': None, 'authmechanismproperties': None, 'host': 'mongomock://localhost:27017/flask_mongoengine_test_db', ...}
    conn_host = ['mongomock://localhost:27017/flask_mongoengine_test_db'] resolved_hosts = []
    entity = 'mongomock://localhost:27017/flask_mongoengine_test_db'

    def _get_connection_settings(
    db=None,
    name=None,
    host=None,
    port=None,
    read_preference=READ_PREFERENCE,
    username=None,
    password=None,
    authentication_source=None,
    authentication_mechanism=None,
    authmechanismproperties=None,
    **kwargs,
    ):
    """Get the connection settings as a dict

    :param db: the name of the database to use, for compatibility with connect
    :param name: the name of the specific database to use
    :param host: the host name of the: program: `mongod` instance to connect to
    :param port: the port that the: program: `mongod` instance is running on
    :param read_preference: The read preference for the collection
    :param username: username to authenticate with
    :param password: password to authenticate with
    :param authentication_source: database to authenticate against
    :param authentication_mechanism: database authentication mechanisms.
    By default, use SCRAM-SHA-1 with MongoDB 3.0 and later,
    MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
    :param mongo_client_class: using alternative connection client other than
    pymongo.MongoClient, e.g. mongomock, montydb, that provides pymongo alike
    interface but not necessarily for connecting to a real mongo instance.
    :param kwargs: ad-hoc parameters to be passed into the pymongo driver,
    for example maxpoolsize, tz_aware, etc. See the documentation
    for pymongo's `MongoClient` for a full list.
    """
    conn_settings = {
    "name": name or db or DEFAULT_DATABASE_NAME,
    "host": host or DEFAULT_HOST,
    "port": port or DEFAULT_PORT,
    "read_preference": read_preference,
    "username": username,
    "password": password,
    "authentication_source": authentication_source,
    "authentication_mechanism": authentication_mechanism,
    "authmechanismproperties": authmechanismproperties,
    }

    _check_db_name(conn_settings["name"])
    conn_host = conn_settings["host"]

    # Host can be a list or a string, so if string, force to a list.
    if isinstance(conn_host, str):
    conn_host = [conn_host]

    resolved_hosts = []
    for entity in conn_host:
    # Reject old mongomock integration
    # To be removed in a few versions after 0.27.0
    if entity.startswith("mongomock://") or kwargs.get("is_mock"):
    raise Exception(
    "Use of mongomock:// URI or 'is_mock' were removed in favor of 'mongo_client_class=mongomock.MongoClient'. "
    "Check the CHANGELOG for more info"
    )

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)