Skip to content

Commit 01e4bc9

Browse files
author
Thordata
committed
fix: update CI workflow and fix tests for v1.1.1
- Fix CI workflow: Update Python versions to 3.10+ (remove 3.9) - Update import verification to include all 8 tools - Fix test suite: Remove deprecated ThordataUniversalTool references - Update tests to use new SDK API (serp_search_advanced, universal.scrape) - Add tests for ThordataMarkdownTool and ThordataAccountTool - Update version to 1.1.1 - Fix CHANGELOG dates
1 parent 1d9c030 commit 01e4bc9

File tree

5 files changed

+64
-43
lines changed

5 files changed

+64
-43
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.10", "3.11", "3.12"]
1616

1717
steps:
1818
- uses: actions/checkout@v4
@@ -41,7 +41,7 @@ jobs:
4141
4242
- name: Verify imports
4343
run: |
44-
python -c "from thordata_langchain_tools import ThordataSerpTool, ThordataScrapeTool, ThordataUniversalTool, ThordataProxyTool; print('✅ All imports OK')"
44+
python -c "from thordata_langchain_tools import ThordataSerpTool, ThordataScrapeTool, ThordataMarkdownTool, ThordataBatchScrapeTool, ThordataBatchSerpTool, ThordataProxyTool, ThordataTaskTool, ThordataAccountTool; print('✅ All imports OK')"
4545
4646
build:
4747
runs-on: ubuntu-latest
@@ -64,4 +64,4 @@ jobs:
6464
run: python -m build
6565

6666
- name: Check package
67-
run: twine check dist/*
67+
run: twine check dist/*

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.1.1] - 2026-02-13
4+
5+
### Fixed
6+
- Fixed CI workflow: Updated Python versions (3.10+), fixed import verification
7+
- Updated test suite to match current tool structure
8+
- Removed references to deprecated ThordataUniversalTool
9+
310
## [1.1.0] - 2026-02-13
411

512
### Added

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "thordata-langchain-tools"
7-
version = "1.1.0"
7+
version = "1.1.1"
88
description = "LangChain tools powered by Thordata - SERP API, Web Scraping, and Proxy Network."
99
readme = "README.md"
1010
requires-python = ">=3.10"
@@ -63,7 +63,7 @@ include = ["thordata_langchain_tools*"]
6363

6464
[tool.black]
6565
line-length = 88
66-
target-version = ['py39', 'py310', 'py311', 'py312']
66+
target-version = ['py310', 'py311', 'py312']
6767

6868
[tool.ruff]
6969
line-length = 88

test/test_tools.py

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from thordata_langchain_tools import (
88
ThordataSerpTool,
99
ThordataScrapeTool,
10-
ThordataUniversalTool,
10+
ThordataMarkdownTool,
1111
ThordataProxyTool,
12+
ThordataAccountTool,
1213
)
1314

1415

@@ -36,7 +37,7 @@ def test_run_success(self, mock_client_class):
3637
"""Test successful SERP search."""
3738
# Setup mock
3839
mock_client = MagicMock()
39-
mock_client.serp_search.return_value = {
40+
mock_client.serp_search_advanced.return_value = {
4041
"organic": [{"title": "Test Result", "link": "https://example.com"}]
4142
}
4243
mock_client_class.return_value = mock_client
@@ -48,13 +49,13 @@ def test_run_success(self, mock_client_class):
4849
# Verify
4950
assert "organic" in result
5051
assert len(result["organic"]) == 1
51-
mock_client.serp_search.assert_called_once()
52+
mock_client.serp_search_advanced.assert_called_once()
5253

5354
@patch("thordata_langchain_tools.serp_tool.ThordataClient")
5455
def test_run_error_handling(self, mock_client_class):
5556
"""Test error handling in SERP search."""
5657
mock_client = MagicMock()
57-
mock_client.serp_search.side_effect = Exception("API Error")
58+
mock_client.serp_search_advanced.side_effect = Exception("API Error")
5859
mock_client_class.return_value = mock_client
5960

6061
tool = ThordataSerpTool()
@@ -80,20 +81,20 @@ def test_tool_description(self):
8081
def test_run_success(self, mock_client_class):
8182
"""Test successful scrape."""
8283
mock_client = MagicMock()
83-
mock_client.universal_scrape.return_value = "<html><body>Test</body></html>"
84+
mock_client.universal.scrape.return_value = "<html><body>Test</body></html>"
8485
mock_client_class.return_value = mock_client
8586

8687
tool = ThordataScrapeTool()
8788
result = tool._run(url="https://example.com", js_render=False, max_length=1000)
8889

8990
assert "html" in result.lower()
90-
mock_client.universal_scrape.assert_called_once()
91+
mock_client.universal.scrape.assert_called_once()
9192

9293
@patch("thordata_langchain_tools.scrape_tool.ThordataClient")
9394
def test_run_truncates_long_content(self, mock_client_class):
9495
"""Test that long content is truncated."""
9596
mock_client = MagicMock()
96-
mock_client.universal_scrape.return_value = "x" * 100000
97+
mock_client.universal.scrape.return_value = "x" * 100000
9798
mock_client_class.return_value = mock_client
9899

99100
tool = ThordataScrapeTool()
@@ -103,46 +104,31 @@ def test_run_truncates_long_content(self, mock_client_class):
103104
assert "truncated" in result.lower()
104105

105106

106-
class TestThordataUniversalTool:
107-
"""Tests for ThordataUniversalTool."""
107+
class TestThordataMarkdownTool:
108+
"""Tests for ThordataMarkdownTool."""
108109

109110
def test_tool_name(self):
110111
"""Test tool has correct name."""
111-
tool = ThordataUniversalTool()
112-
assert tool.name == "thordata_universal_scrape"
112+
tool = ThordataMarkdownTool()
113+
assert tool.name == "thordata_fetch_markdown"
113114

114115
def test_tool_description(self):
115116
"""Test tool has description."""
116-
tool = ThordataUniversalTool()
117-
assert (
118-
"scrape" in tool.description.lower()
119-
or "scraping" in tool.description.lower()
120-
)
121-
122-
@patch("thordata_langchain_tools.universal_tool.ThordataClient")
123-
def test_run_with_js_render(self, mock_client_class):
124-
"""Test scrape with JS rendering."""
117+
tool = ThordataMarkdownTool()
118+
assert "markdown" in tool.description.lower()
119+
120+
@patch("thordata_langchain_tools.markdown_tool.ThordataClient")
121+
def test_run_success(self, mock_client_class):
122+
"""Test successful markdown conversion."""
125123
mock_client = MagicMock()
126-
mock_client.universal_scrape.return_value = "<html>Rendered</html>"
124+
mock_client.universal.scrape.return_value = "<html><body>Test</body></html>"
127125
mock_client_class.return_value = mock_client
128126

129-
tool = ThordataUniversalTool()
130-
result = tool._run(
131-
url="https://example.com",
132-
js_render=True,
133-
output_format="html",
134-
country="us",
135-
wait_for=".content",
136-
)
127+
tool = ThordataMarkdownTool()
128+
result = tool._run(url="https://example.com", js_render=False, max_chars=1000)
137129

138-
assert "html" in result.lower()
139-
mock_client.universal_scrape.assert_called_once_with(
140-
url="https://example.com",
141-
js_render=True,
142-
output_format="html",
143-
country="us",
144-
wait_for=".content",
145-
)
130+
assert isinstance(result, str)
131+
assert len(result) > 0
146132

147133

148134
class TestThordataProxyTool:
@@ -173,3 +159,31 @@ def test_run_basic_request(self, mock_client_class):
173159
result = tool._run(url="https://httpbin.org/ip")
174160

175161
assert "1.2.3.4" in result
162+
163+
164+
class TestThordataAccountTool:
165+
"""Tests for ThordataAccountTool."""
166+
167+
def test_tool_name(self):
168+
"""Test tool has correct name."""
169+
tool = ThordataAccountTool()
170+
assert tool.name == "thordata_account_info"
171+
172+
def test_tool_description(self):
173+
"""Test tool has description."""
174+
tool = ThordataAccountTool()
175+
assert "account" in tool.description.lower()
176+
177+
@patch("thordata_langchain_tools.account_tool.ThordataClient")
178+
def test_run_success(self, mock_client_class):
179+
"""Test successful account info retrieval."""
180+
mock_client = MagicMock()
181+
mock_client.get_traffic_balance.return_value = 1000.0
182+
mock_client.account.get_usage_statistics.return_value = {"total": 500}
183+
mock_client_class.return_value = mock_client
184+
185+
tool = ThordataAccountTool()
186+
result = tool._run()
187+
188+
assert "traffic_balance" in result
189+
assert result["traffic_balance"] == 1000.0

thordata_langchain_tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
>>> markdown = markdown_tool.invoke({"url": "https://example.com"})
2727
"""
2828

29-
__version__ = "1.1.0"
29+
__version__ = "1.1.1"
3030

3131
from .serp_tool import ThordataSerpTool
3232
from .scrape_tool import ThordataScrapeTool

0 commit comments

Comments
 (0)