mirror of
https://github.com/apache/superset.git
synced 2026-05-08 09:25:56 +00:00
- Introduced generic `list` and `count` methods to BaseDAO for consistent querying and counting across all DAOs. - Both methods support filtering (including IN queries), ordering, pagination, search across columns, custom FAB-style filters, and always-on base filters. - Added comprehensive unit tests for `list` and `count` in `tests/unit_tests/dao/base_test.py`, covering: - Filtering (including boolean, None, and IN queries) - Ordering (asc/desc, multiple columns) - Pagination (including out-of-range) - Search across columns - Custom filter logic - Always-on base filter logic - Edge cases and skip_base_filter - Moved common test fixtures to `conftest.py` for reuse.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import pytest
|
|
from flask_appbuilder.security.sqla.models import User
|
|
|
|
|
|
@pytest.fixture
|
|
def user_with_data(session):
|
|
User.metadata.create_all(session.get_bind())
|
|
user = User(
|
|
id=101,
|
|
username="testuser",
|
|
first_name="Test",
|
|
last_name="User",
|
|
email="testuser@example.com",
|
|
active=True,
|
|
)
|
|
session.add(user)
|
|
session.commit()
|
|
yield session
|
|
session.rollback()
|