Skip to content

test_get_list_with_simple_filter_relationship_custom_qs_api test failure #66

Open
@apteryks

Description

@apteryks

Hi,

The following test fails:

==================================== ERRORS ====================================
_ ERROR at setup of test_get_list_with_simple_filter_relationship_custom_qs_api _

client = <FlaskClient <Flask 'tests.conftest'>>, app = <Flask 'tests.conftest'>
api_blueprint = <Blueprint 'api'>
custom_query_string_manager = <class 'tests.test_sqlalchemy_data_layer.custom_query_string_manager.<locals>.QS'>
person_list_2 = <class 'tests.test_sqlalchemy_data_layer.person_list_2.<locals>.PersonList'>

    @pytest.fixture(scope="module")
    def register_routes_custom_qs(
            client,
            app,
            api_blueprint,
            custom_query_string_manager,
            person_list_2,
    ):
        api = Api(blueprint=api_blueprint, qs_manager_class=custom_query_string_manager)
        api.route(person_list_2, "person_list_qs", "/qs/persons")
>       api.init_app(app)

tests/test_sqlalchemy_data_layer.py:655: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
flask_combo_jsonapi/api.py:59: in init_app
    self.app.register_blueprint(self.blueprint)
/gnu/store/4rlh2lfp2p6hdpsdsvcd8b05hm97vw86-python-flask-2.1.1/lib/python3.9/site-packages/flask/scaffold.py:56: in wrapper_func
    return f(self, *args, **kwargs)
/gnu/store/4rlh2lfp2p6hdpsdsvcd8b05hm97vw86-python-flask-2.1.1/lib/python3.9/site-packages/flask/app.py:1028: in register_blueprint
    blueprint.register(self, options)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Blueprint 'api'>, app = <Flask 'tests.conftest'>, options = {}

    def register(self, app: "Flask", options: dict) -> None:
        """Called by :meth:`Flask.register_blueprint` to register all
        views and callbacks registered on the blueprint with the
        application. Creates a :class:`.BlueprintSetupState` and calls
        each :meth:`record` callback with it.
    
        :param app: The application this blueprint is being registered
            with.
        :param options: Keyword arguments forwarded from
            :meth:`~Flask.register_blueprint`.
    
        .. versionchanged:: 2.0.1
            Nested blueprints are registered with their dotted name.
            This allows different blueprints with the same name to be
            nested at different locations.
    
        .. versionchanged:: 2.0.1
            The ``name`` option can be used to change the (pre-dotted)
            name the blueprint is registered with. This allows the same
            blueprint to be registered multiple times with unique names
            for ``url_for``.
    
        .. versionchanged:: 2.0.1
            Registering the same blueprint with the same name multiple
            times is deprecated and will become an error in Flask 2.1.
        """
        name_prefix = options.get("name_prefix", "")
        self_name = options.get("name", self.name)
        name = f"{name_prefix}.{self_name}".lstrip(".")
    
        if name in app.blueprints:
            bp_desc = "this" if app.blueprints[name] is self else "a different"
            existing_at = f" '{name}'" if self_name != name else ""
    
>           raise ValueError(
                f"The name '{self_name}' is already registered for"
                f" {bp_desc} blueprint{existing_at}. Use 'name=' to"
                f" provide a unique name."
            )
E           ValueError: The name 'api' is already registered for this blueprint. Use 'name=' to provide a unique name.

/gnu/store/4rlh2lfp2p6hdpsdsvcd8b05hm97vw86-python-flask-2.1.1/lib/python3.9/site-packages/flask/blueprints.py:305: ValueError
=============================== warnings summary ===============================
tests/conftest.py:12
  /tmp/guix-build-python-flask-combo-jsonapi-1.1.0.drv-0/source/tests/conftest.py:12: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
  Use @pytest.fixture instead; they are the same.
    @pytest.yield_fixture(scope="session")

tests/test_sqlalchemy_data_layer.py::test_get_list
  /tmp/guix-build-python-flask-combo-jsonapi-1.1.0.drv-0/source/tests/test_sqlalchemy_data_layer.py:181: SAWarning: relationship 'Person.computers_owned' will copy column person.person_id to column computer.person_id, which conflicts with relationship(s): 'Computer.person' (copies person.person_id to computer.person_id), 'Person.computers' (copies person.person_id to computer.person_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="computers,person"' to the 'Person.computers_owned' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
    person_ = person_model(name="test")

tests/test_sqlalchemy_data_layer.py::test_delete_detail
  /tmp/guix-build-python-flask-combo-jsonapi-1.1.0.drv-0/source/tests/test_sqlalchemy_data_layer.py:187: SAWarning: DELETE statement on table 'person' expected to delete 1 row(s); 0 were matched.  Please set confirm_deleted_rows=False within the mapper configuration to prevent this warning.
    session_.commit()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
ERROR tests/test_sqlalchemy_data_layer.py::test_get_list_with_simple_filter_relationship_custom_qs_api
=================== 118 passed, 3 warnings, 1 error in 1.29s ===================

Tested on GNU Guix with Python 3.9.9 and the following dependencies:

python-apispec@4.0.0 python-coverage@5.2.1 python-coveralls@3.2.0 python-flask@2.1.1
+ python-marshmallow-jsonapi@0.24.0 python-marshmallow@3.9.1 python-pytest-runner@5.2 python-pytest@6.2.5
+ python-simplejson@3.17.2 python-six@1.16.0 python-sqlalchemy@1.4.35

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions