Skip to content

Commit 374c8d6

Browse files
committed
Fix unit test
1 parent 5b815c1 commit 374c8d6

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

tests/unit/data/test_bulk_import.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ImportErrorMode as ImportErrorModeGeneratedClass,
77
)
88

9-
from pinecone.db_data.features.bulk_import import ImportFeatureMixin, ImportErrorMode
9+
from pinecone.db_data.resources.sync.bulk_import import BulkImportResource, ImportErrorMode
1010

1111

1212
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):
1919
mock_request = mocker.patch.object(
2020
api_client.rest_client.pool_manager, "request", return_value=response
2121
)
22-
return ImportFeatureMixin(api_client=api_client), mock_request
22+
return BulkImportResource(api_client=api_client), mock_request
2323

2424

2525
class TestBulkImportStartImport:
26-
def test_start_import_minimal(self, mocker):
26+
def test_start_minimal(self, mocker):
2727
body = """
2828
{
2929
"id": "1"
3030
}
3131
"""
3232
client, mock_req = build_client_w_faked_response(mocker, body)
3333

34-
my_import = client.start_import("s3://path/to/file.parquet")
34+
my_import = client.start("s3://path/to/file.parquet")
3535

3636
# We made some overrides to the print behavior, so we need to
3737
# call it to ensure it doesn't raise an exception
@@ -42,17 +42,15 @@ def test_start_import_minimal(self, mocker):
4242
assert my_import.to_dict() == {"id": "1"}
4343
assert my_import.__class__ == StartImportResponse
4444

45-
def test_start_import_with_kwargs(self, mocker):
45+
def test_start_with_kwargs(self, mocker):
4646
body = """
4747
{
4848
"id": "1"
4949
}
5050
"""
5151
client, mock_req = build_client_w_faked_response(mocker, body)
5252

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")
5654
assert my_import.id == "1"
5755
assert my_import["id"] == "1"
5856
assert my_import.to_dict() == {"id": "1"}
@@ -68,37 +66,37 @@ def test_start_import_with_kwargs(self, mocker):
6866
@pytest.mark.parametrize(
6967
"error_mode_input", [ImportErrorMode.CONTINUE, "Continue", "continue", "cONTINUE"]
7068
)
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):
7270
body = """
7371
{
7472
"id": "1"
7573
}
7674
"""
7775
client, mock_req = build_client_w_faked_response(mocker, body)
7876

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)
8078
_, call_kwargs = mock_req.call_args
8179
assert (
8280
call_kwargs["body"]
8381
== '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "continue"}}'
8482
)
8583

86-
def test_start_import_with_abort_error_mode(self, mocker):
84+
def test_start_with_abort_error_mode(self, mocker):
8785
body = """
8886
{
8987
"id": "1"
9088
}
9189
"""
9290
client, mock_req = build_client_w_faked_response(mocker, body)
9391

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)
9593
_, call_kwargs = mock_req.call_args
9694
assert (
9795
call_kwargs["body"]
9896
== '{"uri": "s3://path/to/file.parquet", "errorMode": {"onError": "abort"}}'
9997
)
10098

101-
def test_start_import_with_unknown_error_mode(self, mocker):
99+
def test_start_with_unknown_error_mode(self, mocker):
102100
body = """
103101
{
104102
"id": "1"
@@ -107,7 +105,7 @@ def test_start_import_with_unknown_error_mode(self, mocker):
107105
client, mock_req = build_client_w_faked_response(mocker, body)
108106

109107
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")
111109

112110
assert "Invalid error_mode: unknown" in str(e.value)
113111

@@ -122,7 +120,7 @@ def test_start_invalid_uri(self, mocker):
122120
client, mock_req = build_client_w_faked_response(mocker, body, 400)
123121

124122
with pytest.raises(PineconeApiException) as e:
125-
client.start_import(uri="invalid path")
123+
client.start(uri="invalid path")
126124

127125
assert e.value.status == 400
128126
assert e.value.body == body
@@ -134,7 +132,7 @@ def test_no_arguments(self, mocker):
134132
client, mock_req = build_client_w_faked_response(mocker, "")
135133

136134
with pytest.raises(TypeError) as e:
137-
client.start_import()
135+
client.start()
138136

139137
assert "missing 1 required positional argument" in str(e.value)
140138

@@ -162,7 +160,7 @@ def test_describe_import(self, mocker):
162160
"""
163161
client, mock_req = build_client_w_faked_response(mocker, body)
164162

165-
my_import = client.describe_import(id="1")
163+
my_import = client.describe(id="1")
166164

167165
# We made some overrides to the print behavior, so we need to
168166
# call it to ensure it doesn't raise an exception

0 commit comments

Comments
 (0)