1
1
import pytest
2
- import warnings
3
2
4
3
from urllib3 import BaseHTTPResponse
5
4
@@ -36,17 +35,16 @@ def test_start_import_minimal(self, mocker):
36
35
"""
37
36
client , mock_req = build_client_w_faked_response (mocker , body )
38
37
39
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
40
- my_import = client .start_import ("s3://path/to/file.parquet" )
38
+ my_import = client .start_import ("s3://path/to/file.parquet" )
41
39
42
- # We made some overrides to the print behavior, so we need to
43
- # call it to ensure it doesn't raise an exception
44
- print (my_import )
40
+ # We made some overrides to the print behavior, so we need to
41
+ # call it to ensure it doesn't raise an exception
42
+ print (my_import )
45
43
46
- assert my_import .id == "1"
47
- assert my_import ["id" ] == "1"
48
- assert my_import .to_dict () == {"id" : "1" }
49
- assert my_import .__class__ == StartImportResponse
44
+ assert my_import .id == "1"
45
+ assert my_import ["id" ] == "1"
46
+ assert my_import .to_dict () == {"id" : "1" }
47
+ assert my_import .__class__ == StartImportResponse
50
48
51
49
def test_start_import_with_kwargs (self , mocker ):
52
50
body = """
@@ -56,19 +54,18 @@ def test_start_import_with_kwargs(self, mocker):
56
54
"""
57
55
client , mock_req = build_client_w_faked_response (mocker , body )
58
56
59
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
60
- my_import = client .start_import (uri = "s3://path/to/file.parquet" , integration_id = "123-456-789" )
61
- assert my_import .id == "1"
62
- assert my_import ["id" ] == "1"
63
- assert my_import .to_dict () == {"id" : "1" }
64
- assert my_import .__class__ == StartImportResponse
57
+ my_import = client .start_import (uri = "s3://path/to/file.parquet" , integration_id = "123-456-789" )
58
+ assert my_import .id == "1"
59
+ assert my_import ["id" ] == "1"
60
+ assert my_import .to_dict () == {"id" : "1" }
61
+ assert my_import .__class__ == StartImportResponse
65
62
66
- # By default, use continue error mode
67
- _ , call_kwargs = mock_req .call_args
68
- assert (
69
- call_kwargs ["body" ]
70
- == '{"uri": "s3://path/to/file.parquet", "integrationId": "123-456-789", "errorMode": {"onError": "continue"}}'
71
- )
63
+ # By default, use continue error mode
64
+ _ , call_kwargs = mock_req .call_args
65
+ assert (
66
+ call_kwargs ["body" ]
67
+ == '{"uri": "s3://path/to/file.parquet", "integrationId": "123-456-789", "errorMode": {"onError": "continue"}}'
68
+ )
72
69
73
70
@pytest .mark .parametrize (
74
71
"error_mode_input" ,
@@ -87,10 +84,9 @@ def test_start_import_with_explicit_error_mode(self, mocker, error_mode_input):
87
84
"""
88
85
client , mock_req = build_client_w_faked_response (mocker , body )
89
86
90
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
91
- my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = error_mode_input )
92
- _ , call_kwargs = mock_req .call_args
93
- assert call_kwargs ["body" ] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'
87
+ my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = error_mode_input )
88
+ _ , call_kwargs = mock_req .call_args
89
+ assert call_kwargs ["body" ] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'
94
90
95
91
def test_start_import_with_abort_error_mode (self , mocker ):
96
92
body = """
@@ -100,10 +96,9 @@ def test_start_import_with_abort_error_mode(self, mocker):
100
96
"""
101
97
client , mock_req = build_client_w_faked_response (mocker , body )
102
98
103
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
104
- my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = ImportErrorMode .ABORT )
105
- _ , call_kwargs = mock_req .call_args
106
- assert call_kwargs ["body" ] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'
99
+ my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = ImportErrorMode .ABORT )
100
+ _ , call_kwargs = mock_req .call_args
101
+ assert call_kwargs ["body" ] == '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'
107
102
108
103
def test_start_import_with_unknown_error_mode (self , mocker ):
109
104
body = """
@@ -113,11 +108,10 @@ def test_start_import_with_unknown_error_mode(self, mocker):
113
108
"""
114
109
client , mock_req = build_client_w_faked_response (mocker , body )
115
110
116
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
117
- with pytest .raises (ValueError ) as e :
118
- my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = "unknown" )
111
+ with pytest .raises (ValueError ) as e :
112
+ my_import = client .start_import (uri = "s3://path/to/file.parquet" , error_mode = "unknown" )
119
113
120
- assert "Invalid error_mode value: unknown" in str (e .value )
114
+ assert "Invalid error_mode value: unknown" in str (e .value )
121
115
122
116
def test_start_invalid_uri (self , mocker ):
123
117
body = """
@@ -129,9 +123,8 @@ def test_start_invalid_uri(self, mocker):
129
123
"""
130
124
client , mock_req = build_client_w_faked_response (mocker , body , 400 )
131
125
132
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
133
- with pytest .raises (PineconeApiException ) as e :
134
- my_import = client .start_import (uri = "invalid path" )
126
+ with pytest .raises (PineconeApiException ) as e :
127
+ my_import = client .start_import (uri = "invalid path" )
135
128
136
129
assert e .value .status == 400
137
130
assert e .value .body == body
@@ -140,9 +133,8 @@ def test_start_invalid_uri(self, mocker):
140
133
def test_no_arguments (self , mocker ):
141
134
client , mock_req = build_client_w_faked_response (mocker , "" )
142
135
143
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
144
- with pytest .raises (TypeError ) as e :
145
- client .start_import ()
136
+ with pytest .raises (TypeError ) as e :
137
+ client .start_import ()
146
138
147
139
assert "missing 1 required positional argument" in str (e .value )
148
140
@@ -165,17 +157,16 @@ def test_describe_import(self, mocker):
165
157
"""
166
158
client , mock_req = build_client_w_faked_response (mocker , body )
167
159
168
- with pytest .warns (UserWarning , match = "The bulk import feature is in early access" ):
169
- my_import = client .describe_import (id = "1" )
160
+ my_import = client .describe_import (id = "1" )
170
161
171
- # We made some overrides to the print behavior, so we need to
172
- # call it to ensure it doesn't raise an exception
173
- print (my_import )
162
+ # We made some overrides to the print behavior, so we need to
163
+ # call it to ensure it doesn't raise an exception
164
+ print (my_import )
174
165
175
- assert my_import .id == "1"
176
- assert my_import ["id" ] == "1"
177
- desc = my_import .to_dict ()
178
- assert desc ["id" ] == "1"
179
- assert desc ["records_imported" ] == 1000
180
- assert desc ["uri" ] == "s3://path/to/file.parquet"
181
- assert desc ["status" ] == "InProgress"
166
+ assert my_import .id == "1"
167
+ assert my_import ["id" ] == "1"
168
+ desc = my_import .to_dict ()
169
+ assert desc ["id" ] == "1"
170
+ assert desc ["records_imported" ] == 1000
171
+ assert desc ["uri" ] == "s3://path/to/file.parquet"
172
+ assert desc ["status" ] == "InProgress"
0 commit comments