6
6
ImportErrorMode as ImportErrorModeGeneratedClass ,
7
7
)
8
8
9
- from pinecone .db_data .features . bulk_import import ImportFeatureMixin , ImportErrorMode
9
+ from pinecone .db_data .resources . sync . bulk_import import BulkImportResource , ImportErrorMode
10
10
11
11
12
12
def build_client_w_faked_response (mocker , body : str , status : int = 200 ):
@@ -19,19 +19,19 @@ def build_client_w_faked_response(mocker, body: str, status: int = 200):
19
19
mock_request = mocker .patch .object (
20
20
api_client .rest_client .pool_manager , "request" , return_value = response
21
21
)
22
- return ImportFeatureMixin (api_client = api_client ), mock_request
22
+ return BulkImportResource (api_client = api_client ), mock_request
23
23
24
24
25
25
class TestBulkImportStartImport :
26
- def test_start_import_minimal (self , mocker ):
26
+ def test_start_minimal (self , mocker ):
27
27
body = """
28
28
{
29
29
"id": "1"
30
30
}
31
31
"""
32
32
client , mock_req = build_client_w_faked_response (mocker , body )
33
33
34
- my_import = client .start_import ("s3://path/to/file.parquet" )
34
+ my_import = client .start ("s3://path/to/file.parquet" )
35
35
36
36
# We made some overrides to the print behavior, so we need to
37
37
# call it to ensure it doesn't raise an exception
@@ -42,17 +42,15 @@ def test_start_import_minimal(self, mocker):
42
42
assert my_import .to_dict () == {"id" : "1" }
43
43
assert my_import .__class__ == StartImportResponse
44
44
45
- def test_start_import_with_kwargs (self , mocker ):
45
+ def test_start_with_kwargs (self , mocker ):
46
46
body = """
47
47
{
48
48
"id": "1"
49
49
}
50
50
"""
51
51
client , mock_req = build_client_w_faked_response (mocker , body )
52
52
53
- my_import = client .start_import (
54
- uri = "s3://path/to/file.parquet" , integration_id = "123-456-789"
55
- )
53
+ my_import = client .start (uri = "s3://path/to/file.parquet" , integration_id = "123-456-789" )
56
54
assert my_import .id == "1"
57
55
assert my_import ["id" ] == "1"
58
56
assert my_import .to_dict () == {"id" : "1" }
@@ -68,37 +66,37 @@ def test_start_import_with_kwargs(self, mocker):
68
66
@pytest .mark .parametrize (
69
67
"error_mode_input" , [ImportErrorMode .CONTINUE , "Continue" , "continue" , "cONTINUE" ]
70
68
)
71
- def test_start_import_with_explicit_error_mode (self , mocker , error_mode_input ):
69
+ def test_start_with_explicit_error_mode (self , mocker , error_mode_input ):
72
70
body = """
73
71
{
74
72
"id": "1"
75
73
}
76
74
"""
77
75
client , mock_req = build_client_w_faked_response (mocker , body )
78
76
79
- client .start_import (uri = "s3://path/to/file.parquet" , error_mode = error_mode_input )
77
+ client .start (uri = "s3://path/to/file.parquet" , error_mode = error_mode_input )
80
78
_ , call_kwargs = mock_req .call_args
81
79
assert (
82
80
call_kwargs ["body" ]
83
81
== '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'
84
82
)
85
83
86
- def test_start_import_with_abort_error_mode (self , mocker ):
84
+ def test_start_with_abort_error_mode (self , mocker ):
87
85
body = """
88
86
{
89
87
"id": "1"
90
88
}
91
89
"""
92
90
client , mock_req = build_client_w_faked_response (mocker , body )
93
91
94
- client .start_import (uri = "s3://path/to/file.parquet" , error_mode = ImportErrorMode .ABORT )
92
+ client .start (uri = "s3://path/to/file.parquet" , error_mode = ImportErrorMode .ABORT )
95
93
_ , call_kwargs = mock_req .call_args
96
94
assert (
97
95
call_kwargs ["body" ]
98
96
== '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'
99
97
)
100
98
101
- def test_start_import_with_unknown_error_mode (self , mocker ):
99
+ def test_start_with_unknown_error_mode (self , mocker ):
102
100
body = """
103
101
{
104
102
"id": "1"
@@ -107,7 +105,7 @@ def test_start_import_with_unknown_error_mode(self, mocker):
107
105
client , mock_req = build_client_w_faked_response (mocker , body )
108
106
109
107
with pytest .raises (ValueError ) as e :
110
- client .start_import (uri = "s3://path/to/file.parquet" , error_mode = "unknown" )
108
+ client .start (uri = "s3://path/to/file.parquet" , error_mode = "unknown" )
111
109
112
110
assert "Invalid error_mode: unknown" in str (e .value )
113
111
@@ -122,7 +120,7 @@ def test_start_invalid_uri(self, mocker):
122
120
client , mock_req = build_client_w_faked_response (mocker , body , 400 )
123
121
124
122
with pytest .raises (PineconeApiException ) as e :
125
- client .start_import (uri = "invalid path" )
123
+ client .start (uri = "invalid path" )
126
124
127
125
assert e .value .status == 400
128
126
assert e .value .body == body
@@ -134,7 +132,7 @@ def test_no_arguments(self, mocker):
134
132
client , mock_req = build_client_w_faked_response (mocker , "" )
135
133
136
134
with pytest .raises (TypeError ) as e :
137
- client .start_import ()
135
+ client .start ()
138
136
139
137
assert "missing 1 required positional argument" in str (e .value )
140
138
@@ -162,7 +160,7 @@ def test_describe_import(self, mocker):
162
160
"""
163
161
client , mock_req = build_client_w_faked_response (mocker , body )
164
162
165
- my_import = client .describe_import (id = "1" )
163
+ my_import = client .describe (id = "1" )
166
164
167
165
# We made some overrides to the print behavior, so we need to
168
166
# call it to ensure it doesn't raise an exception
0 commit comments