Skip to content

fix(freshdesk): upgrade to SDK 2.0.0, add unit tests#287

Merged
Shubhank-Jonnada merged 5 commits into
masterfrom
fix/freshdesk-sdk-upgrade-v2
May 12, 2026
Merged

fix(freshdesk): upgrade to SDK 2.0.0, add unit tests#287
Shubhank-Jonnada merged 5 commits into
masterfrom
fix/freshdesk-sdk-upgrade-v2

Conversation

@Shubhank-Jonnada
Copy link
Copy Markdown
Contributor

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

Summary

  • Upgrade SDK to 2.0.0: use ActionResult/ActionError return types
  • Access FetchResponse.data on all context.fetch() calls
  • Fix auth helper to use the flat custom auth dict (api_key, domain)
  • Remove legacy result/error fields from output schemas
  • Add pytest unit tests following the writing-unit-tests pattern
  • Replace legacy/manual Freshdesk test scripts with a real pytest.mark.integration live suite
  • Remove obsolete freshdesk/tests/context.py
  • Add FRESHDESK_API_KEY and FRESHDESK_DOMAIN to .env.example

Auth/test alignment

Freshdesk is configured with custom auth in config.json:

{
  "type": "custom",
  "fields": {
    "api_key": "...",
    "domain": "..."
  }
}

The unit and live integration tests now match that flat custom-auth shape:

  • env vars: FRESHDESK_API_KEY, FRESHDESK_DOMAIN
  • context auth: {"api_key": api_key, "domain": domain}
  • request auth remains generated by the integration helper as Freshdesk Basic auth (api_key:X)

Integration test coverage

Safe read-only live coverage includes:

  • list_companies
  • get_company when a company exists
  • list_tickets
  • get_ticket when a ticket exists
  • list_contacts
  • get_contact when a contact exists
  • list_conversations when a ticket exists

Safe read-only command:

pytest freshdesk/tests/test_freshdesk_integration.py -m "integration and not destructive"

Test plan

  • .venv/bin/python -m pytest freshdesk/tests -m unit -q — 88 passed
  • .venv/bin/python -m pytest freshdesk/tests/test_freshdesk_integration.py -m "integration and not destructive" -q — 7 skipped without live Freshdesk creds
  • .venv/bin/python -m pytest freshdesk/ -q — 88 passed; integration file not collected by default
  • .venv/bin/python ../autohive-integrations-tooling/scripts/validate_integration.py freshdesk — passed
  • .venv/bin/python ../autohive-integrations-tooling/scripts/check_code.py freshdesk — passed

- Update SDK to 2.0.0: all context.fetch() calls access .data
- Import and use ActionResult/ActionError return types
- Fix auth: use flat context.auth dict (custom auth type)
- Remove legacy result/error fields from all output schemas
- Bump config.json version to 2.0.0
- Add 88 pytest unit tests covering all 17 actions
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

🔍 Integration Validation Results

Commit: 90496d3e3f6b83b4ec112f5346cbfdc44bd32f96 · test(freshdesk): add e2e coverage for all 20 actions, fix note field nullability
Updated: 2026-05-12T02:30:10Z

Changed directories: freshdesk

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

============================================================
Integration: freshdesk
============================================================
✅ All checks passed!

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

✅ All validations passed!
✅ 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: freshdesk
----------------------------------------

📦 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
-------------------------------------------
freshdesk     88/88       94%      ✅ Passed
-------------------------------------------
Total         88/88            ✅ All passed

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

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8d7e545f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread freshdesk/freshdesk.py
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.

SDK 2.0.0 migration looks clean (good catch on the flat context.auth shape for custom auth) and the 88 unit tests provide solid coverage. Local CI verified: validate_integration ✅, check_code ✅, ruff ✅, pytest ✅.

Blocking on one thing: no tests/test_freshdesk_integration.py. Freshdesk uses a custom API-key auth, so adding e2e coverage is low-cost — env vars (FRESHDESK_DOMAIN, FRESHDESK_API_KEY) and the live_context fixture per the writing-integration-tests skill. Please add at minimum read-only smoke coverage for the major endpoints (tickets, contacts, agents) before merge. Mark create/update/delete tests with @pytest.mark.destructive.

Also: branch name doesn't follow <type>/<issue#>/<desc> per AGENTS.md, and no linked issue.

Shubhank-Jonnada and others added 3 commits May 1, 2026 14:47
…n tests

- Replace all `inputs["param"]` with `inputs.get("param")` for optional
  parameters to prevent KeyError if the parameter is not provided
- Add freshdesk/tests/test_freshdesk_integration.py with pytest.mark.integration
  tests that skip when FRESHDESK_API_KEY or FRESHDESK_DOMAIN env vars are missing
TheRealAgentK
TheRealAgentK previously approved these changes May 11, 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.

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

…nullability

- Fixed import in test file (module vs Integration instance)
- Expanded integration tests from 7 to 8 covering all 20 actions
- Added company lifecycle (create, get, update, delete)
- Added contact lifecycle (create, get, update, delete)
- Added ticket lifecycle (create, get, update, list_conversations, create_note, create_reply, delete)
- Added search_companies and search_contacts read-only tests
- Fixed config.json: note field type string -> ["string", "null"] to match Freshdesk API returning null
@Shubhank-Jonnada
Copy link
Copy Markdown
Contributor Author

Live Integration Tests

All 20 actions tested live against the Freshdesk API across 8 test functions.

Test Actions Covered
test_list_companies list_companies
test_list_tickets list_tickets
test_list_contacts list_contacts
test_search_companies search_companies
test_search_contacts search_contacts
test_company_lifecycle create_company, get_company, update_company, delete_company
test_contact_lifecycle create_contact, get_contact, update_contact, delete_contact
test_ticket_lifecycle create_ticket, get_ticket, update_ticket, list_conversations, create_note, create_reply, delete_ticket

8 test functions, 20 actions, 20/20 passing live.

Also caught and fixed a real bug during live testing: note in the output schema was typed as string but Freshdesk returns null for unset fields.

@Shubhank-Jonnada Shubhank-Jonnada merged commit ca47d1f into master May 12, 2026
3 checks passed
@Shubhank-Jonnada Shubhank-Jonnada deleted the fix/freshdesk-sdk-upgrade-v2 branch May 12, 2026 03:26
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.

3 participants