Skip to content

Commit 38380bc

Browse files
chore: update SDK to v0.4.0
1 parent 8ecc5de commit 38380bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+7966
-7956
lines changed

conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
project = "X API SDK"
2222
copyright = "2024, X Developer Platform"
2323
author = "X Developer Platform"
24-
release = "0.3.0"
25-
version = "0.3.0"
24+
release = "0.4.0"
25+
version = "0.4.0"
2626

2727
# -- General configuration ----------------------------------------------------
2828

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build-backend = "hatchling.build"
1414

1515
[project]
1616
name = "xdk"
17-
version = "0.3.0"
17+
version = "0.4.0"
1818
description = "Python SDK for the X API"
1919
authors = [
2020
{name = "X Developer Platform", email = "[email protected]"},

scripts/process-for-mintlify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
MINTLIFY_CONFIG = {
2525
"outputDir": "mintlify-docs",
2626
"baseUrl": "https://docs.x.com",
27-
"title": "X API SDK v0.3.0",
27+
"title": "X API SDK v0.4.0",
2828
"description": "Python SDK for the X API with comprehensive pagination, authentication, and streaming support.",
29-
"version": "0.3.0",
29+
"version": "0.4.0",
3030
"githubUrl": "https://github.com/xdevplatform/xdk",
3131
}
3232

tests/account_activity/test_contracts.py

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

tests/account_activity/test_structure.py

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

tests/activity/test_contracts.py

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

tests/activity/test_structure.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,51 @@ def test_create_subscription_return_annotation(self):
118118
), f"Method create_subscription should have return type annotation"
119119

120120

121+
def test_stream_exists(self):
122+
"""Test that stream method exists with correct signature."""
123+
# Check method exists
124+
method = getattr(ActivityClient, "stream", None)
125+
assert method is not None, f"Method stream does not exist on ActivityClient"
126+
# Check method is callable
127+
assert callable(method), f"stream is not callable"
128+
# Check method signature
129+
sig = inspect.signature(method)
130+
params = list(sig.parameters.keys())
131+
# Should have 'self' as first parameter
132+
assert len(params) >= 1, f"stream should have at least 'self' parameter"
133+
assert (
134+
params[0] == "self"
135+
), f"First parameter should be 'self', got '{params[0]}'"
136+
# Check required parameters exist (excluding 'self')
137+
required_params = []
138+
for required_param in required_params:
139+
assert (
140+
required_param in params
141+
), f"Required parameter '{required_param}' missing from stream"
142+
# Check optional parameters have defaults (excluding 'self')
143+
optional_params = [
144+
"backfill_minutes",
145+
"start_time",
146+
"end_time",
147+
]
148+
for optional_param in optional_params:
149+
if optional_param in params:
150+
param_obj = sig.parameters[optional_param]
151+
assert (
152+
param_obj.default is not inspect.Parameter.empty
153+
), f"Optional parameter '{optional_param}' should have a default value"
154+
155+
156+
def test_stream_return_annotation(self):
157+
"""Test that stream has proper return type annotation."""
158+
method = getattr(ActivityClient, "stream")
159+
sig = inspect.signature(method)
160+
# Check return annotation exists
161+
assert (
162+
sig.return_annotation is not inspect.Signature.empty
163+
), f"Method stream should have return type annotation"
164+
165+
121166
def test_update_subscription_exists(self):
122167
"""Test that update_subscription method exists with correct signature."""
123168
# Check method exists
@@ -212,59 +257,14 @@ def test_delete_subscription_return_annotation(self):
212257
), f"Method delete_subscription should have return type annotation"
213258

214259

215-
def test_stream_exists(self):
216-
"""Test that stream method exists with correct signature."""
217-
# Check method exists
218-
method = getattr(ActivityClient, "stream", None)
219-
assert method is not None, f"Method stream does not exist on ActivityClient"
220-
# Check method is callable
221-
assert callable(method), f"stream is not callable"
222-
# Check method signature
223-
sig = inspect.signature(method)
224-
params = list(sig.parameters.keys())
225-
# Should have 'self' as first parameter
226-
assert len(params) >= 1, f"stream should have at least 'self' parameter"
227-
assert (
228-
params[0] == "self"
229-
), f"First parameter should be 'self', got '{params[0]}'"
230-
# Check required parameters exist (excluding 'self')
231-
required_params = []
232-
for required_param in required_params:
233-
assert (
234-
required_param in params
235-
), f"Required parameter '{required_param}' missing from stream"
236-
# Check optional parameters have defaults (excluding 'self')
237-
optional_params = [
238-
"backfill_minutes",
239-
"start_time",
240-
"end_time",
241-
]
242-
for optional_param in optional_params:
243-
if optional_param in params:
244-
param_obj = sig.parameters[optional_param]
245-
assert (
246-
param_obj.default is not inspect.Parameter.empty
247-
), f"Optional parameter '{optional_param}' should have a default value"
248-
249-
250-
def test_stream_return_annotation(self):
251-
"""Test that stream has proper return type annotation."""
252-
method = getattr(ActivityClient, "stream")
253-
sig = inspect.signature(method)
254-
# Check return annotation exists
255-
assert (
256-
sig.return_annotation is not inspect.Signature.empty
257-
), f"Method stream should have return type annotation"
258-
259-
260260
def test_all_expected_methods_exist(self):
261261
"""Test that all expected methods exist on the client."""
262262
expected_methods = [
263263
"get_subscriptions",
264264
"create_subscription",
265+
"stream",
265266
"update_subscription",
266267
"delete_subscription",
267-
"stream",
268268
]
269269
for expected_method in expected_methods:
270270
assert hasattr(

tests/communities/test_contracts.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def setup_class(self):
2727
self.communities_client = getattr(self.client, "communities")
2828

2929

30-
def test_search_request_structure(self):
31-
"""Test search request structure."""
30+
def test_get_by_id_request_structure(self):
31+
"""Test get_by_id request structure."""
3232
# Mock the session to capture request details
3333
with patch.object(self.client, "session") as mock_session:
3434
mock_response = Mock()
@@ -41,11 +41,11 @@ def test_search_request_structure(self):
4141
# Prepare test parameters
4242
kwargs = {}
4343
# Add required parameters
44-
kwargs["query"] = "test_query"
44+
kwargs["id"] = "test_value"
4545
# Add request body if required
4646
# Call the method
4747
try:
48-
method = getattr(self.communities_client, "search")
48+
method = getattr(self.communities_client, "get_by_id")
4949
result = method(**kwargs)
5050
# Check if this is a streaming operation (returns Generator)
5151
import types
@@ -80,7 +80,7 @@ def test_search_request_structure(self):
8080
called_url = (
8181
call_args[0][0] if call_args[0] else call_args[1].get("url", "")
8282
)
83-
expected_path = "/2/communities/search"
83+
expected_path = "/2/communities/{id}"
8484
assert expected_path.replace("{", "").replace(
8585
"}", ""
8686
) in called_url or any(
@@ -96,12 +96,12 @@ def test_search_request_structure(self):
9696
# For regular operations, verify we got a result
9797
assert result is not None, "Method should return a result"
9898
except Exception as e:
99-
pytest.fail(f"Contract test failed for search: {e}")
99+
pytest.fail(f"Contract test failed for get_by_id: {e}")
100100

101101

102-
def test_search_required_parameters(self):
103-
"""Test that search handles parameters correctly."""
104-
method = getattr(self.communities_client, "search")
102+
def test_get_by_id_required_parameters(self):
103+
"""Test that get_by_id handles parameters correctly."""
104+
method = getattr(self.communities_client, "get_by_id")
105105
# Test with missing required parameters - mock the request to avoid network calls
106106
with patch.object(self.client, "session") as mock_session:
107107
# Mock a 400 response (typical for missing required parameters)
@@ -115,8 +115,8 @@ def test_search_required_parameters(self):
115115
method()
116116

117117

118-
def test_search_response_structure(self):
119-
"""Test search response structure validation."""
118+
def test_get_by_id_response_structure(self):
119+
"""Test get_by_id response structure validation."""
120120
with patch.object(self.client, "session") as mock_session:
121121
# Create mock response with expected structure
122122
mock_response_data = {
@@ -129,10 +129,10 @@ def test_search_response_structure(self):
129129
mock_session.get.return_value = mock_response
130130
# Prepare minimal valid parameters
131131
kwargs = {}
132-
kwargs["query"] = "test_value"
132+
kwargs["id"] = "test"
133133
# Add request body if required
134134
# Call method and verify response structure
135-
method = getattr(self.communities_client, "search")
135+
method = getattr(self.communities_client, "get_by_id")
136136
result = method(**kwargs)
137137
# Verify response object has expected attributes
138138
# Optional field - just check it doesn't cause errors if accessed
@@ -144,8 +144,8 @@ def test_search_response_structure(self):
144144
)
145145

146146

147-
def test_get_by_id_request_structure(self):
148-
"""Test get_by_id request structure."""
147+
def test_search_request_structure(self):
148+
"""Test search request structure."""
149149
# Mock the session to capture request details
150150
with patch.object(self.client, "session") as mock_session:
151151
mock_response = Mock()
@@ -158,11 +158,11 @@ def test_get_by_id_request_structure(self):
158158
# Prepare test parameters
159159
kwargs = {}
160160
# Add required parameters
161-
kwargs["id"] = "test_value"
161+
kwargs["query"] = "test_query"
162162
# Add request body if required
163163
# Call the method
164164
try:
165-
method = getattr(self.communities_client, "get_by_id")
165+
method = getattr(self.communities_client, "search")
166166
result = method(**kwargs)
167167
# Check if this is a streaming operation (returns Generator)
168168
import types
@@ -197,7 +197,7 @@ def test_get_by_id_request_structure(self):
197197
called_url = (
198198
call_args[0][0] if call_args[0] else call_args[1].get("url", "")
199199
)
200-
expected_path = "/2/communities/{id}"
200+
expected_path = "/2/communities/search"
201201
assert expected_path.replace("{", "").replace(
202202
"}", ""
203203
) in called_url or any(
@@ -213,12 +213,12 @@ def test_get_by_id_request_structure(self):
213213
# For regular operations, verify we got a result
214214
assert result is not None, "Method should return a result"
215215
except Exception as e:
216-
pytest.fail(f"Contract test failed for get_by_id: {e}")
216+
pytest.fail(f"Contract test failed for search: {e}")
217217

218218

219-
def test_get_by_id_required_parameters(self):
220-
"""Test that get_by_id handles parameters correctly."""
221-
method = getattr(self.communities_client, "get_by_id")
219+
def test_search_required_parameters(self):
220+
"""Test that search handles parameters correctly."""
221+
method = getattr(self.communities_client, "search")
222222
# Test with missing required parameters - mock the request to avoid network calls
223223
with patch.object(self.client, "session") as mock_session:
224224
# Mock a 400 response (typical for missing required parameters)
@@ -232,8 +232,8 @@ def test_get_by_id_required_parameters(self):
232232
method()
233233

234234

235-
def test_get_by_id_response_structure(self):
236-
"""Test get_by_id response structure validation."""
235+
def test_search_response_structure(self):
236+
"""Test search response structure validation."""
237237
with patch.object(self.client, "session") as mock_session:
238238
# Create mock response with expected structure
239239
mock_response_data = {
@@ -246,10 +246,10 @@ def test_get_by_id_response_structure(self):
246246
mock_session.get.return_value = mock_response
247247
# Prepare minimal valid parameters
248248
kwargs = {}
249-
kwargs["id"] = "test"
249+
kwargs["query"] = "test_value"
250250
# Add request body if required
251251
# Call method and verify response structure
252-
method = getattr(self.communities_client, "get_by_id")
252+
method = getattr(self.communities_client, "search")
253253
result = method(**kwargs)
254254
# Verify response object has expected attributes
255255
# Optional field - just check it doesn't cause errors if accessed

0 commit comments

Comments
 (0)