Skip to content

Commit cb80d0a

Browse files
feat(gong): upgrade SDK to 2.0.0, add pytest unit tests (#282)
* feat(gong): upgrade SDK to 2.0.0, add pytest unit tests - Bump autohive-integrations-sdk to ~=2.0.0 - Update _make_request to return response.data (FetchResponse breaking change) - Convert all error returns to ActionError(message=...) - Move GongAPIClient instantiation inside try blocks for consistent error handling - Normalize None field values to empty strings/defaults to satisfy output schema - Bump config.json version to 2.0.0 - Add gong/tests/conftest.py and test_gong_unit.py with 32 unit tests covering all 5 actions: happy path, request verification, error paths, and edge cases * fix(gong): fix check_code warning and rewrite integration tests with proper SDK 2.0 patterns - Use limit param in search_calls to resolve config-code sync warning - Rewrite test_gong_integration.py with pytest.mark.integration, skipif guard for missing GONG_ACCESS_TOKEN, FetchResponse mocks, and proper ResultType assertions * fix(gong): fix auth, optional params, add proper unit and integration tests - Fix test_gong_unit.py to work with SDK 2.0.0: remove FetchResponse import, use plain dict mocks, fix error assertions to check result.result.data.get("error") instead of ActionError.message since gong.py returns ActionResult for all cases - Add GONG_ACCESS_KEY and GONG_ACCESS_KEY_SECRET to .env.example * fix(gong): fix gong.py for SDK 2.0.0 — remove ActionError, fix fetch return, rewrite tests * fix(gong): complete sdk v2 error handling * test(gong): align live tests with OAuth auth * fix(gong): correct integration test import to use gong.gong module * test(gong): use fake call ID to exercise all actions when account has no calls --------- Co-authored-by: Shubhank <72601061+Sagsgit@users.noreply.github.com> Co-authored-by: Kai Koenig <kai@ventego-creative.co.nz>
1 parent a42bc7d commit cb80d0a

8 files changed

Lines changed: 771 additions & 389 deletions

File tree

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
# (uses platform OAuth — tokens are short-lived, typically not set here)
6262

6363
# -- Gong --
64-
# GONG_ACCESS_KEY=
65-
# GONG_ACCESS_KEY_SECRET=
64+
# GONG_ACCESS_TOKEN=
65+
# GONG_API_BASE_URL=
6666

6767
# -- Float --
6868
# FLOAT_API_KEY=

gong/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Gong",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "An integration with Gong to access call recordings, transcripts, and CRM data.",
55
"entry_point": "gong.py",
66
"auth": {

gong/gong.py

Lines changed: 92 additions & 128 deletions
Large diffs are not rendered by default.

gong/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
autohive-integrations-sdk~=1.0.2
1+
autohive-integrations-sdk~=2.0.0
22
python-dateutil

gong/tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
import sys
3+
from unittest.mock import AsyncMock, MagicMock
4+
5+
import pytest
6+
7+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
8+
9+
10+
@pytest.fixture
11+
def mock_context():
12+
"""Mock execution context with the platform OAuth shape Gong expects."""
13+
ctx = MagicMock(name="ExecutionContext")
14+
ctx.fetch = AsyncMock(name="fetch")
15+
ctx.auth = {
16+
"auth_type": "PlatformOauth2",
17+
"credentials": {"access_token": "test_token"}, # nosec B105
18+
}
19+
ctx.metadata = {"api_base_url": "https://api.gong.io"}
20+
return ctx

gong/tests/context.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)