Dataverse-Python-Testing-Debugging
Dataverse-Python-Testing-Debugging是一款code方向的AI技能,核心价值是# Dataverse SDK for Python — Testing & Debugging Strategies Based on official Azure Functions and pytest testing patterns,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
# Dataverse SDK for Python — Testing & Debugging Strategies Based on official Azure Functions and pytest testing patterns. ## 1. Testing Overview ### Testing Pyramid for Dataverse SDK ```
mkdir -p ./skills/dataverse-python-testing-debugging && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/dataverse-python-testing-debugging/SKILL.md -o ./skills/dataverse-python-testing-debugging/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# Dataverse SDK for Python — Testing & Debugging Strategies
Based on official Azure Functions and pytest testing patterns.
1. Testing Overview
Testing Pyramid for Dataverse SDK
Integration Tests <- Test with real Dataverse
/\
/ \
/Unit Tests (Mocked)\
/____________________\
< Framework Tests---
2. Unit Testing with Mocking
Setup Test Environment
# Install test dependencies
pip install pytest pytest-cov unittest-mockMock DataverseClient
# tests/test_operations.py
import pytest
from unittest.mock import Mock, patch, MagicMock
from PowerPlatform.Dataverse.client import DataverseClient
@pytest.fixture
def mock_client():
"""Provide mocked DataverseClient."""
client = Mock(spec=DataverseClient)
return client
def test_create_account(mock_client):
"""Test account creation with mocked client."""
# Setup mock response
mock_client.create.return_value = ["id-123"]
# Call function
from my_app import create_account
result = create_account(mock_client, {"name": "Acme"})
# Verify
assert result == "id-123"
mock_client.create.assert_called_once_with("account", {"name": "Acme"})
def test_create_account_error(mock_client):
"""Test error handling in account creation."""
from PowerPlatform.Dataverse.core.errors import DataverseError
# Setup mock to raise error
mock_client.create.side_effect = DataverseError(
message="Account exists",
code="validation_error",
status_code=400
)
# Verify error is raised
from my_app import create_account
with pytest.raises(DataverseError):
create_account(mock_client, {"name": "Acme"})Test Data Structures
# tests/fixtures.py
import pytest
@pytest.fixture
def sample_account():
"""Sample account record for testing."""
return {
"accountid": "id-123",
"name": "Acme Inc",
"telephone1": "555-0100",
"statecode": 0,
"createdon": "2025-01-01T00:00:00Z"
}
@pytest.fixture
def sample_accounts(sample_account):
"""Multiple sample accounts."""
return [
sample_account,
{**sample_account, "accountid": "id-124", "name": "Fabrikam"},
{**sample_account, "accountid": "id-125", "name": "Contoso"},
]
# Usage in tests
def test_process_accounts(mock_client, sample_accounts):
mock_client.get.return_value = iter([sample_accounts])
# Test processing---
3. Mocking Common Patterns
Mock Get with Pagination
def test_pagination(mock_client, sample_accounts):
"""Test handling paginated results."""
# Mock returns generator with pages
mock_client.get.return_value = iter([
sample_accounts[:2], # Page 1
sample_accounts[2:] # Page 2
])
from my_app import process_all_accounts
result = process_all_accounts(mock_client)
assert len(result) == 3 # All pages processedMock Bulk Operations
def test_bulk_create(mock_client):
"""Test bulk account creation."""
payloads = [
{"name": "Account 1"},
{"name": "Account 2"},
]
# Mock returns list of IDs
mock_client.create.return_value = ["id-1", "id-2"]
from my_app import create_accounts
ids = create_accounts(mock_client, payloads)
assert len(ids) == 2
mock_client.create.assert_called_once_with("account", payloads)Mock Errors
def test_rate_limiting_retry(mock_client):
"""Test retry logic on rate limiting."""
from PowerPlatform.Dataverse.core.errors import DataverseError
# Mock fails then succeeds
error = DataverseError(
message="Too many requests",
code="http_error",
status_code=429,
is_transient=True
)
mock_client.create.side_effect = [error, ["id-123"]]
from my_app import 🎯 Best For
- Debugging engineers
- QA teams
- QA engineers
- Developers writing unit tests
- Claude users
💡 Use Cases
- Tracing runtime errors in production logs
- Identifying memory leaks
- Generating test cases for edge conditions
- Writing integration test suites
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Dataverse-Python-Testing-Debugging to Your Work
Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.
- 4
Review and Refine
Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.
❓ Frequently Asked Questions
Can this debug production issues?
Yes, but always ensure you have proper logging and monitoring in place first.
Does this generate test mocks?
Many testing skills include mock generation. Check the install command and skill content for details.
Is Dataverse-Python-Testing-Debugging compatible with Cursor and VS Code?
Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.
Do I need specific dependencies for Dataverse-Python-Testing-Debugging?
Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.
How do I install Dataverse-Python-Testing-Debugging?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/dataverse-python-testing-debugging/SKILL.md, ready to use.
⚠️ Common Mistakes to Avoid
Debugging without context
Always provide the full error stack and surrounding code context for accurate debugging.
Not testing edge cases
AI tends to generate happy-path tests. Manually review for boundary conditions.
Skipping validation
Always test AI-generated code changes, even for simple refactors.
Missing dependency updates
Check if the skill requires updated dependencies or new packages.