xparse-client 0.2.19__py3-none-any.whl → 0.3.0b8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. example/1_basic_api_usage.py +198 -0
  2. example/2_async_job.py +210 -0
  3. example/3_local_workflow.py +300 -0
  4. example/4_advanced_workflow.py +327 -0
  5. example/README.md +128 -0
  6. example/config_example.json +95 -0
  7. tests/conftest.py +310 -0
  8. tests/unit/__init__.py +1 -0
  9. tests/unit/api/__init__.py +1 -0
  10. tests/unit/api/test_extract.py +232 -0
  11. tests/unit/api/test_local.py +231 -0
  12. tests/unit/api/test_parse.py +374 -0
  13. tests/unit/api/test_pipeline.py +369 -0
  14. tests/unit/api/test_workflows.py +108 -0
  15. tests/unit/connectors/test_ftp.py +525 -0
  16. tests/unit/connectors/test_local_connectors.py +324 -0
  17. tests/unit/connectors/test_milvus.py +368 -0
  18. tests/unit/connectors/test_qdrant.py +399 -0
  19. tests/unit/connectors/test_s3.py +598 -0
  20. tests/unit/connectors/test_smb.py +442 -0
  21. tests/unit/connectors/test_utils.py +335 -0
  22. tests/unit/models/test_local.py +54 -0
  23. tests/unit/models/test_pipeline_stages.py +144 -0
  24. tests/unit/models/test_workflows.py +55 -0
  25. tests/unit/test_base.py +437 -0
  26. tests/unit/test_client.py +110 -0
  27. tests/unit/test_config.py +160 -0
  28. tests/unit/test_exceptions.py +182 -0
  29. tests/unit/test_http.py +562 -0
  30. xparse_client/__init__.py +111 -20
  31. xparse_client/_base.py +188 -0
  32. xparse_client/_client.py +218 -0
  33. xparse_client/_config.py +221 -0
  34. xparse_client/_http.py +351 -0
  35. xparse_client/api/__init__.py +14 -0
  36. xparse_client/api/extract.py +109 -0
  37. xparse_client/api/local.py +225 -0
  38. xparse_client/api/parse.py +209 -0
  39. xparse_client/api/pipeline.py +134 -0
  40. xparse_client/api/workflows.py +204 -0
  41. xparse_client/connectors/__init__.py +45 -0
  42. xparse_client/connectors/_utils.py +138 -0
  43. xparse_client/connectors/destinations/__init__.py +45 -0
  44. xparse_client/connectors/destinations/base.py +116 -0
  45. xparse_client/connectors/destinations/local.py +91 -0
  46. xparse_client/connectors/destinations/milvus.py +229 -0
  47. xparse_client/connectors/destinations/qdrant.py +238 -0
  48. xparse_client/connectors/destinations/s3.py +163 -0
  49. xparse_client/connectors/sources/__init__.py +45 -0
  50. xparse_client/connectors/sources/base.py +74 -0
  51. xparse_client/connectors/sources/ftp.py +278 -0
  52. xparse_client/connectors/sources/local.py +176 -0
  53. xparse_client/connectors/sources/s3.py +232 -0
  54. xparse_client/connectors/sources/smb.py +259 -0
  55. xparse_client/exceptions.py +398 -0
  56. xparse_client/models/__init__.py +60 -0
  57. xparse_client/models/chunk.py +39 -0
  58. xparse_client/models/embed.py +62 -0
  59. xparse_client/models/extract.py +41 -0
  60. xparse_client/models/local.py +38 -0
  61. xparse_client/models/parse.py +132 -0
  62. xparse_client/models/pipeline.py +134 -0
  63. xparse_client/models/workflows.py +74 -0
  64. xparse_client-0.3.0b8.dist-info/METADATA +1075 -0
  65. xparse_client-0.3.0b8.dist-info/RECORD +68 -0
  66. {xparse_client-0.2.19.dist-info → xparse_client-0.3.0b8.dist-info}/WHEEL +1 -1
  67. {xparse_client-0.2.19.dist-info → xparse_client-0.3.0b8.dist-info}/licenses/LICENSE +1 -1
  68. {xparse_client-0.2.19.dist-info → xparse_client-0.3.0b8.dist-info}/top_level.txt +2 -0
  69. xparse_client/pipeline/__init__.py +0 -3
  70. xparse_client/pipeline/config.py +0 -129
  71. xparse_client/pipeline/destinations.py +0 -489
  72. xparse_client/pipeline/pipeline.py +0 -690
  73. xparse_client/pipeline/sources.py +0 -583
  74. xparse_client-0.2.19.dist-info/METADATA +0 -1050
  75. xparse_client-0.2.19.dist-info/RECORD +0 -11
@@ -0,0 +1,182 @@
1
+ """异常类测试"""
2
+
3
+
4
+ from xparse_client.exceptions import (
5
+ APIError,
6
+ AuthenticationError,
7
+ ConfigurationError,
8
+ ConnectorError,
9
+ DestinationError,
10
+ NotFoundError,
11
+ PermissionDeniedError,
12
+ PipelineError,
13
+ RateLimitError,
14
+ RequestTimeoutError,
15
+ ServerError,
16
+ SourceError,
17
+ ValidationError,
18
+ XParseClientError,
19
+ )
20
+
21
+
22
+ class TestXParseClientError:
23
+ """基础异常类测试"""
24
+
25
+ def test_basic_error(self):
26
+ """测试基础错误创建"""
27
+ error = XParseClientError("测试错误")
28
+ assert error.message == "测试错误"
29
+ assert error.details == {}
30
+ assert str(error) == "测试错误"
31
+
32
+ def test_error_with_details(self):
33
+ """测试带详情的错误"""
34
+ error = XParseClientError("测试错误", details={"key": "value"})
35
+ assert error.details == {"key": "value"}
36
+ assert "key=value" in str(error)
37
+
38
+ def test_to_dict(self):
39
+ """测试序列化为字典"""
40
+ error = XParseClientError("测试错误", details={"key": "value"})
41
+ result = error.to_dict()
42
+ assert result["error_type"] == "XParseClientError"
43
+ assert result["message"] == "测试错误"
44
+ assert result["details"] == {"key": "value"}
45
+
46
+
47
+ class TestConfigurationError:
48
+ """配置错误测试"""
49
+
50
+ def test_configuration_error(self):
51
+ """测试配置错误"""
52
+ error = ConfigurationError(
53
+ "缺少必要参数",
54
+ details={"missing": ["app_id"]},
55
+ )
56
+ assert isinstance(error, XParseClientError)
57
+ assert error.message == "缺少必要参数"
58
+
59
+
60
+ class TestValidationError:
61
+ """验证错误测试"""
62
+
63
+ def test_validation_error_with_field(self):
64
+ """测试带字段信息的验证错误"""
65
+ error = ValidationError(
66
+ "无效的值",
67
+ field="filename",
68
+ value="test.xyz",
69
+ )
70
+ assert error.field == "filename"
71
+ assert error.value == "test.xyz"
72
+ assert "field" in error.details
73
+ assert "value" in error.details
74
+
75
+
76
+ class TestAPIError:
77
+ """API 错误测试"""
78
+
79
+ def test_api_error_with_status(self):
80
+ """测试带状态码的 API 错误"""
81
+ error = APIError(
82
+ "请求失败",
83
+ status_code=500,
84
+ request_id="req-123",
85
+ )
86
+ assert error.status_code == 500
87
+ assert error.request_id == "req-123"
88
+ assert "status=500" in str(error)
89
+ assert "request_id=req-123" in str(error)
90
+
91
+ def test_authentication_error(self):
92
+ """测试认证错误"""
93
+ error = AuthenticationError(
94
+ "无效的 API 密钥",
95
+ status_code=401,
96
+ )
97
+ assert isinstance(error, APIError)
98
+ assert error.status_code == 401
99
+
100
+ def test_permission_denied_error(self):
101
+ """测试权限错误"""
102
+ error = PermissionDeniedError(
103
+ "无权访问",
104
+ status_code=403,
105
+ )
106
+ assert isinstance(error, APIError)
107
+
108
+ def test_not_found_error(self):
109
+ """测试资源不存在错误"""
110
+ error = NotFoundError(
111
+ "资源不存在",
112
+ resource_type="job",
113
+ resource_id="job-123",
114
+ status_code=404,
115
+ )
116
+ assert error.resource_type == "job"
117
+ assert error.resource_id == "job-123"
118
+
119
+ def test_rate_limit_error(self):
120
+ """测试限流错误"""
121
+ error = RateLimitError(
122
+ "请求过于频繁",
123
+ retry_after=60,
124
+ status_code=429,
125
+ )
126
+ assert error.retry_after == 60
127
+
128
+ def test_server_error(self):
129
+ """测试服务器错误"""
130
+ error = ServerError(
131
+ "内部服务器错误",
132
+ status_code=500,
133
+ )
134
+ assert isinstance(error, APIError)
135
+
136
+ def test_timeout_error(self):
137
+ """测试超时错误"""
138
+ error = RequestTimeoutError(
139
+ "请求超时",
140
+ timeout_seconds=30.0,
141
+ )
142
+ assert error.timeout_seconds == 30.0
143
+
144
+
145
+ class TestConnectorError:
146
+ """连接器错误测试"""
147
+
148
+ def test_source_error(self):
149
+ """测试数据源错误"""
150
+ error = SourceError(
151
+ "无法连接 S3",
152
+ connector_type="s3",
153
+ operation="connect",
154
+ )
155
+ assert error.connector_type == "s3"
156
+ assert error.operation == "connect"
157
+ assert isinstance(error, ConnectorError)
158
+
159
+ def test_destination_error(self):
160
+ """测试目的地错误"""
161
+ error = DestinationError(
162
+ "写入 Milvus 失败",
163
+ connector_type="milvus",
164
+ operation="write",
165
+ )
166
+ assert error.connector_type == "milvus"
167
+ assert isinstance(error, ConnectorError)
168
+
169
+
170
+ class TestPipelineError:
171
+ """Pipeline 错误测试"""
172
+
173
+ def test_pipeline_error(self):
174
+ """测试 Pipeline 错误"""
175
+ error = PipelineError(
176
+ "处理文件失败",
177
+ stage="parse",
178
+ filename="test.pdf",
179
+ )
180
+ assert error.stage == "parse"
181
+ assert error.filename == "test.pdf"
182
+ assert isinstance(error, XParseClientError)