Skip to content

feat(powerbi): upgrade SDK to 2.0.0, add pytest unit tests#286

Open
Shubhank-Jonnada wants to merge 4 commits into
masterfrom
worktree-agent-a2238685871d724a3
Open

feat(powerbi): upgrade SDK to 2.0.0, add pytest unit tests#286
Shubhank-Jonnada wants to merge 4 commits into
masterfrom
worktree-agent-a2238685871d724a3

Conversation

@Shubhank-Jonnada
Copy link
Copy Markdown
Contributor

@Shubhank-Jonnada Shubhank-Jonnada commented Apr 28, 2026

Summary

  • Upgrades autohive-integrations-sdk from ~=1.0.2 to ~=2.0.0
  • All context.fetch() return values now access .data for the response body
  • All error paths converted from bare dicts to ActionError(message=...)
  • All success paths converted from bare dicts to ActionResult(data=..., cost_usd=0.0)
  • Removed legacy "result" boolean and "error" fields from output schemas in config.json
  • Made nullable API fields accept ["string", "null"] types in output schemas
  • Bumped config.json version to 2.0.0
  • Added Power BI unit tests across workspaces, datasets, reports, dashboards, and queries
  • Replaced the legacy mocked test_powerbi_integration.py with a real live pytest.mark.integration suite using env_credentials, make_context, FetchResponse, and platform OAuth-style POWERBI_ACCESS_TOKEN
  • Removed obsolete powerbi/tests/context.py
  • Added POWERBI_ACCESS_TOKEN to .env.example

Auth/test alignment

Power BI is configured as platform OAuth in config.json:

{"type": "platform", "provider": "Power BI"}

The live tests now match that shape:

  • env var: POWERBI_ACCESS_TOKEN
  • request header: Authorization: Bearer <token>
  • context auth: {"auth_type": "PlatformOauth2", "credentials": {"access_token": token}}

Closes #300

Integration test coverage

The live read-only suite covers the requested domains:

  • workspaces: list_workspaces, plus get_workspace when a workspace exists
  • datasets: list_datasets
  • reports: list_reports
  • dashboards: list_dashboards
  • queries: execute_queries when a dataset exists

Safe read-only command:

pytest powerbi/tests/test_powerbi_integration.py -m "integration and not destructive"

Test plan

  • .venv/bin/python -m pytest powerbi/tests -m unit -q — 82 passed
  • .venv/bin/python -m pytest powerbi/tests/test_powerbi_integration.py -m "integration and not destructive" -q — 6 skipped without live Power BI creds
  • .venv/bin/python -m pytest powerbi/ -q — 82 passed; integration file not collected by default
  • .venv/bin/python ../autohive-integrations-tooling/scripts/validate_integration.py powerbi — passed with one existing scope warning (offline_access, Content.Create, Tenant.ReadWrite.All)
  • .venv/bin/python ../autohive-integrations-tooling/scripts/check_code.py powerbi — passed

- Bump autohive-integrations-sdk to ~=2.0.0
- Add .data accessor to all context.fetch() return values
- Convert all error paths to ActionError(message=...)
- Convert all success paths to ActionResult(data=..., cost_usd=0.0)
- Remove "result" and "error" fields from all output schemas
- Make nullable API fields accept ["string", "null"] in config.json
- Bump config.json version to 2.0.0
- Add 68 unit tests covering happy path, request verification, error paths, and edge cases
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

🔍 Integration Validation Results

Commit: 3b5d838b17777ec1cb8c18b9fb020b71b88774aa · test(powerbi): replace mocked integration suite
Updated: 2026-05-11T20:40:53Z

Changed directories: powerbi

Check Result
Structure ⚠️ Passed with warnings
Code ✅ Passed
Tests ✅ Passed
README ✅ Passed
Version ✅ Passed
⚠️ Structure Check output
Validating 1 integration(s)...

============================================================
Integration: powerbi
============================================================

Warnings (1):
  ⚠️ Potentially unused scopes (please verify): offline_access, Content.Create, Tenant.ReadWrite.All

============================================================
SUMMARY
============================================================
Integrations validated: 1
Total errors: 0
Total warnings: 1

⚠️ Validation passed with warnings - please review
✅ Code Check output

[notice] A new release of pip is available: 26.0.1 -> 26.1.1
[notice] To update, run: pip install --upgrade pip
----------------------------------------
Checking: powerbi
----------------------------------------

📦 Installing dependencies...

🐍 Checking Python syntax...
   ✅ Syntax OK

📥 Checking imports...
   ✅ Imports OK

📄 Checking JSON files...
   ✅ JSON files OK

🔍 Linting with ruff...
   ✅ Lint OK

🎨 Checking formatting with ruff...
   ✅ Formatting OK

🔒 Scanning for security issues with bandit...
   ✅ Security OK

🛡️ Checking dependencies for vulnerabilities with pip-audit...
   ✅ Dependencies OK

🔗 Checking config-code sync...
   ✅ Config-code sync OK

🔄 Checking fetch patterns...
   ✅ Fetch patterns OK

========================================
✅ CODE CHECK PASSED
========================================
✅ Tests Check output

Integration   Tests  Coverage        Status
-------------------------------------------
powerbi     82/82       96%      ✅ Passed
-------------------------------------------
Total       82/82            ✅ All passed

✅ Tests passed: powerbi
✅ README Check output
========================================
✅ README CHECK PASSED
========================================
✅ Version Check output
✅ powerbi: 1.0.0 → 2.0.0 (major bump)

========================================
✅ VERSION CHECK PASSED
========================================

TheRealAgentK
TheRealAgentK previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Collaborator

@TheRealAgentK TheRealAgentK left a comment

Choose a reason for hiding this comment

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

LGTM. SDK 2.0.0 migration is clean — context.fetch().data, ActionError(message=...) everywhere, schema envelope fields removed, version bumped. Sensible call to make nullable Power BI fields accept ["string", "null"] in the output schema. 68 new unit tests on top of existing coverage (82 total).

Local CI verified: validate_integration ✅, check_code ✅, ruff ✅, pytest ✅.

tests/test_powerbi_integration.py already exists in master — please confirm in your test plan that you've re-run it against a real Power BI workspace on this branch to verify the v2 changes don't regress live behaviour.

Process nit: branch worktree-agent-* doesn't follow <type>/<issue#>/<desc> per AGENTS.md and no linked issue. Please follow the convention next time.

@TheRealAgentK
Copy link
Copy Markdown
Collaborator

Correction to my earlier review: I misread the existing powerbi/tests/test_powerbi_integration.py as a real e2e suite. On a closer look, it's a unittest.TestCase using AsyncMock/Mock for ExecutionContext — its own docstring says "without making actual API calls to Power BI". The filename is misleading.

Approval still stands (the SDK 2.0.0 migration in this PR is shippable as-is and is now superseded for unit coverage by the new test_powerbi_*_unit.py files), but a real live_context-based integration suite is still missing for Power BI.

Tracked in #300 — please address in a follow-up PR.

Copy link
Copy Markdown
Collaborator

@TheRealAgentK TheRealAgentK left a comment

Choose a reason for hiding this comment

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

Self-approved to remove the block, needs 3rd party review and then e-2-e test runs.

Copy link
Copy Markdown
Collaborator

@TheRealAgentK TheRealAgentK left a comment

Choose a reason for hiding this comment

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

Self-approved to remove the block, needs 3rd party review and then e-2-e test runs.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(powerbi): replace mocked test_powerbi_integration.py with real live_context suite

2 participants