Skip to content

Add e2e relationship tests for pre-GA validation#152

Open
saurabhrb wants to merge 5 commits intomainfrom
users/saurabhrb/e2e-relationship-tests
Open

Add e2e relationship tests for pre-GA validation#152
saurabhrb wants to merge 5 commits intomainfrom
users/saurabhrb/e2e-relationship-tests

Conversation

@saurabhrb
Copy link
Contributor

Summary

Add end-to-end relationship tests that validate the full relationship API lifecycle against a live Dataverse environment. This is the primary pre-GA validation for Tim's relationship PRs (#88, #105, #114).

Changes

New: tests/e2e/test_relationships_e2e.py

11 curated e2e tests covering:

Test Class Tests Coverage
TestOneToManyCore 1 Full 1:N lifecycle: create, get, delete, field assertions
TestLookupField 1 Convenience create_lookup_field to system table
TestManyToMany 2 N:N lifecycle + nonexistent returns None
TestDataThroughRelationships 4 @odata.bind, $expand, $filter on lookup, update binding
TestCascadeBehaviors 2 Restrict blocks delete; Cascade deletes children
TestTypeDetection 1 get_relationship distinguishes 1:N vs N:N

Updated: examples/basic/functional_testing.py

  • Added relationship testing section covering 1:N core API, convenience API, N:N, get, and delete
  • Added relationship imports and retry helpers

Updated: pyproject.toml

  • Added [tool.pytest.ini_options] with testpaths = ["tests/unit"]
  • Default pytest runs only unit tests; e2e tests require explicit invocation

How to run e2e tests

# Set your Dataverse org URL
export DATAVERSE_URL=https://yourorg.crm.dynamics.com

# Run relationship e2e tests
pytest tests/e2e/ -v -s

The tests authenticate via InteractiveBrowserCredential and create/delete temporary tables (prefixed test_E2E*).

E2E Test Results (from .scratch/ comprehensive suite)

Ran 30 tests against https://aurorabapenv71aff.crm10.dynamics.com:

  • 25/30 passed on first run
  • 5 failures were test bugs (not SDK bugs), all fixed:
    • Metadata propagation timing (increased retries)
    • Navigation property name casing ($expand needs server-assigned nav prop)
    • IsValidForAdvancedFind requires BooleanManagedProperty complex type

Finding: SDK inconsistency to address before GA

create_one_to_many_relationship() returns lookup_schema_name as the user-provided SchemaName, but $expand requires the server-assigned ReferencingEntityNavigationPropertyName (which may differ in casing). The e2e tests work around this by calling get_relationship() after create to get the correct nav prop name. This should be harmonized before GA.

Checklist

  • 398 unit tests pass
  • 11 e2e tests collected by pytest
  • Default pytest excludes e2e (runs unit only)
  • Code formatted with black
  • Branch rebased on origin/main

- Add tests/e2e/test_relationships_e2e.py with 11 curated e2e tests covering:
  - 1:N core API lifecycle (create, get, delete)
  - 1:N convenience API (create_lookup_field to system table)
  - N:N lifecycle and nonexistent returns None
  - Data through relationships (@odata.bind, $expand, $filter, update binding)
  - Cascade behaviors (Restrict blocks delete, Cascade deletes children)
  - Type detection (get_relationship distinguishes 1:N vs N:N)
- Add relationship testing to examples/basic/functional_testing.py
- Configure pytest to exclude e2e from default run (requires DATAVERSE_URL env var)
- E2e tests run with: DATAVERSE_URL=https://yourorg.crm.dynamics.com pytest tests/e2e/ -v -s
Copilot AI review requested due to automatic review settings March 18, 2026 05:01
@saurabhrb saurabhrb requested a review from a team as a code owner March 18, 2026 05:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a live-environment end-to-end (e2e) test suite to validate the Dataverse relationships API lifecycle prior to GA, plus updates local tooling/docs so unit tests remain the default.

Changes:

  • Introduces tests/e2e/test_relationships_e2e.py with relationship lifecycle, data-through-relationship, and cascade behavior validation against a real Dataverse org.
  • Expands examples/basic/functional_testing.py with a new relationship testing section and retry helpers.
  • Updates pyproject.toml pytest configuration so default pytest runs only tests/unit (e2e requires explicit invocation).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
tests/e2e/test_relationships_e2e.py New live-org e2e suite validating 1:N, N:N, relationship-driven data ops, cascade behaviors, and type detection.
tests/e2e/init.py Adds package marker for the new e2e tests directory.
examples/basic/functional_testing.py Adds relationship functional testing workflow and retry helper in the example script.
pyproject.toml Configures pytest default discovery to run unit tests only.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Saurabh Badenkal added 3 commits March 18, 2026 10:08
- Switch all table/column/relationship names from test_ to new_ prefix
  (follows Dataverse convention for custom entity publisher prefix)
- Use PascalCase nav prop for @odata.bind and \ (case-sensitive)
- Use lowercase attribute logical name for _xxx_value in \/\
- Replace time.sleep() with _wait_for_lookup_ready() polling helper
- Replace cascade delete time.sleep() with retry polling for 404
- Add pytestmark = pytest.mark.e2e and register marker in pyproject.toml
- Close DataverseClient in fixture teardown
- Read DATAVERSE_URL lazily for late-set env vars

Validated: all 30 .scratch/ e2e tests pass (25 original + 5 fixed)
Validated: all 11 repo e2e tests collected, 398 unit tests pass
@saurabhrb saurabhrb requested a review from Copilot March 18, 2026 19:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new end-to-end (live Dataverse) test suite to validate the full relationship API lifecycle (1:N, N:N, lookup helper, data operations via relationships, cascade behaviors) as part of pre-GA verification for the relationships feature set.

Changes:

  • Added tests/e2e/test_relationships_e2e.py with 11 live-environment relationship e2e tests and supporting retry/wait helpers.
  • Updated examples/basic/functional_testing.py to include an interactive relationship testing section (create/get/delete for 1:N, lookup helper, and N:N).
  • Updated pyproject.toml pytest config to default to unit tests only and to register the e2e marker.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/e2e/test_relationships_e2e.py New live Dataverse e2e suite validating relationship CRUD, data operations via relationships, and cascade behavior.
tests/e2e/init.py Adds package marker for the new e2e tests directory.
pyproject.toml Configures pytest to run unit tests by default and registers the e2e marker.
examples/basic/functional_testing.py Extends functional testing script with interactive relationship lifecycle checks and retry helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@saurabhrb saurabhrb self-assigned this Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants