Skip to content

Commit cba7f8b

Browse files
author
Saurabh Badenkal
committed
Fix e2e tests: switch to new_ prefix, address PR review comments
- 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
1 parent 08d55d0 commit cba7f8b

3 files changed

Lines changed: 141 additions & 74 deletions

File tree

examples/basic/functional_testing.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ def test_relationships(client: DataverseClient) -> None:
432432

433433
try:
434434
# --- Cleanup any leftover resources from previous run ---
435-
print("Cleaning up previous relationship test resources...")
435+
print("Checking for leftover relationship test resources...")
436+
found_leftovers = False
436437
for rel_name in [
437438
"test_RelParent_RelChild",
438439
"contact_test_relchild_test_ManagerId",
@@ -441,18 +442,45 @@ def test_relationships(client: DataverseClient) -> None:
441442
try:
442443
rel = client.tables.get_relationship(rel_name)
443444
if rel:
444-
client.tables.delete_relationship(rel.relationship_id)
445-
print(f" (Cleaned up relationship: {rel_name})")
445+
found_leftovers = True
446+
break
446447
except Exception:
447448
pass
448449

449-
for tbl in [rel_child_schema, rel_parent_schema, rel_m2m_schema]:
450-
try:
451-
if client.tables.get(tbl):
452-
client.tables.delete(tbl)
453-
print(f" (Cleaned up table: {tbl})")
454-
except Exception:
455-
pass
450+
if not found_leftovers:
451+
for tbl in [rel_child_schema, rel_parent_schema, rel_m2m_schema]:
452+
try:
453+
if client.tables.get(tbl):
454+
found_leftovers = True
455+
break
456+
except Exception:
457+
pass
458+
459+
if found_leftovers:
460+
cleanup_ok = input("Found leftover test resources. Clean up? (y/N): ").strip().lower() in ["y", "yes"]
461+
if cleanup_ok:
462+
for rel_name in [
463+
"test_RelParent_RelChild",
464+
"contact_test_relchild_test_ManagerId",
465+
"test_relchild_relproject",
466+
]:
467+
try:
468+
rel = client.tables.get_relationship(rel_name)
469+
if rel:
470+
client.tables.delete_relationship(rel.relationship_id)
471+
print(f" (Cleaned up relationship: {rel_name})")
472+
except Exception:
473+
pass
474+
475+
for tbl in [rel_child_schema, rel_parent_schema, rel_m2m_schema]:
476+
try:
477+
if client.tables.get(tbl):
478+
client.tables.delete(tbl)
479+
print(f" (Cleaned up table: {tbl})")
480+
except Exception:
481+
pass
482+
else:
483+
print("Skipping cleanup -- resources may conflict with new test run.")
456484

457485
# --- Create parent and child tables ---
458486
print("\nCreating relationship test tables...")

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@ select = [
9393

9494
[tool.pytest.ini_options]
9595
testpaths = ["tests/unit"]
96+
markers = [
97+
"e2e: end-to-end tests requiring a live Dataverse environment (DATAVERSE_URL)",
98+
]
9699
# e2e tests require a live Dataverse environment:
97100
# DATAVERSE_URL=https://yourorg.crm.dynamics.com pytest tests/e2e/ -v -s

0 commit comments

Comments
 (0)