Skip to content

Added geospatial tests for $near#218

Merged
eerxuan merged 4 commits into
documentdb:mainfrom
vic-tsang:geospatial/near/tests
May 27, 2026
Merged

Added geospatial tests for $near#218
eerxuan merged 4 commits into
documentdb:mainfrom
vic-tsang:geospatial/near/tests

Conversation

@vic-tsang
Copy link
Copy Markdown
Collaborator

This PR contains:

  • geospatial tests for $near
  • added conftest.py under geospatial to enable index creation with 2dsphere and 2d to be used with nearSphere later

Ref:

@vic-tsang vic-tsang requested a review from a team as a code owner May 20, 2026 17:14
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels May 20, 2026
@documentdb-triage-tool
Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort L · Status Needs Review
Confidence: 0.85 (mixed)

Reasoning

component from path globs (test-coverage, test-framework); effort from diff stats (1691+0 LOC, 11 files); LLM: Adds new geospatial $near test cases under the compatibility tests directory, expanding test coverage for an important query operator.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

Signed-off-by: Victor [C] Tsang <[email protected]>
@vic-tsang vic-tsang force-pushed the geospatial/near/tests branch from e4ccd92 to ff0efac Compare May 21, 2026 00:57
@vic-tsang vic-tsang force-pushed the geospatial/near/tests branch from a6e9f98 to d4cc5fd Compare May 21, 2026 18:30
Signed-off-by: Victor [C] Tsang <[email protected]>
@vic-tsang vic-tsang requested a review from fanyangv May 26, 2026 21:29
@fanyangv fanyangv mentioned this pull request May 26, 2026
@eerxuan eerxuan merged commit 8bf8c38 into documentdb:main May 27, 2026
12 checks passed


@pytest.fixture
def geo_2dsphere(collection):
Copy link
Copy Markdown
Collaborator

@eerxuan eerxuan May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this, remember to keep each test case self-contained: has setup command and expected. So

pytestmark = pytest.mark.usefixtures("geo_2dsphere")

file level fixture breaks the pattern.

Also, you have fixture and inline create_index, which means this fixture is not flexible enough.

Please remove the fixture. We should have consistent format for index setup and collection setup.
We can create a similar index helpers as the CustomCollection etc. This can keep the self-contained test case pattern, and it is flexible enough so we can have TestCase specific index setup.

    CommandTestCase(
        "collation_null_uses_default",
        target_collection=CustomCollection(options={"collation": {"locale": "en", "strength": 2}}),
        docs=[{"_id": 1, "s": "abc"}, {"_id": 2, "s": "ABC"}, {"_id": 3, "s": "def"}],
        command=lambda ctx: {
            "count": ctx.collection,
            "query": {"s": "abc"},
            "collation": None,
        },
        expected={"n": 2, "ok": 1.0},
        msg="count with collation=null should use collection default collation",
    ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants