superb-ai-onprem 0.2.0__py3-none-any.whl → 0.3.0__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.
Potentially problematic release.
This version of superb-ai-onprem might be problematic. Click here for more details.
- spb_onprem/__init__.py +8 -1
- spb_onprem/_version.py +2 -2
- spb_onprem/data/enums/data_type.py +2 -1
- spb_onprem/entities.py +3 -1
- spb_onprem/exports/__init__.py +9 -0
- spb_onprem/exports/entities/__init__.py +7 -0
- spb_onprem/exports/entities/export.py +27 -0
- spb_onprem/exports/params/__init__.py +19 -0
- spb_onprem/exports/params/create_export.py +85 -0
- spb_onprem/exports/params/delete_export.py +30 -0
- spb_onprem/exports/params/export.py +30 -0
- spb_onprem/exports/params/exports.py +74 -0
- spb_onprem/exports/params/update_export.py +98 -0
- spb_onprem/exports/queries.py +158 -0
- spb_onprem/exports/service.py +224 -0
- spb_onprem/searches.py +6 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.0.dist-info}/METADATA +1 -1
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.0.dist-info}/RECORD +27 -10
- tests/exports/__init__.py +1 -0
- tests/exports/real_test.py +130 -0
- tests/exports/test_entities.py +236 -0
- tests/exports/test_integration.py +191 -0
- tests/exports/test_params.py +332 -0
- tests/exports/test_service.py +406 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.0.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Integration test for the exports module.
|
|
3
|
+
This test demonstrates how to use the exports module in a real scenario.
|
|
4
|
+
Note: This test is commented out as it requires actual API credentials and dataset.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from spb_onprem.exports import ExportService, ExportFilterOptions
|
|
8
|
+
from spb_onprem.exports.params import ExportFilter
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_export_service_integration():
|
|
12
|
+
"""
|
|
13
|
+
Integration test for ExportService.
|
|
14
|
+
|
|
15
|
+
This test demonstrates the complete workflow of:
|
|
16
|
+
1. Creating an export
|
|
17
|
+
2. Getting exports with filtering
|
|
18
|
+
3. Getting a specific export
|
|
19
|
+
4. Updating an export
|
|
20
|
+
5. Deleting an export
|
|
21
|
+
|
|
22
|
+
Note: This test is commented out as it requires actual API connection.
|
|
23
|
+
"""
|
|
24
|
+
# Uncomment the following lines to run with real API
|
|
25
|
+
|
|
26
|
+
# # Initialize the service
|
|
27
|
+
# export_service = ExportService()
|
|
28
|
+
# dataset_id = "your_dataset_id_here"
|
|
29
|
+
|
|
30
|
+
# # 1. Create an export
|
|
31
|
+
# new_export = export_service.create_export(
|
|
32
|
+
# dataset_id=dataset_id,
|
|
33
|
+
# name="Test Export from SDK",
|
|
34
|
+
# data_filter={"must": {"keyContains": "validation"}},
|
|
35
|
+
# meta={"created_by": "integration_test", "purpose": "testing"}
|
|
36
|
+
# )
|
|
37
|
+
# print(f"Created export: {new_export.id}")
|
|
38
|
+
|
|
39
|
+
# # 2. Get exports with filtering
|
|
40
|
+
# export_filter = ExportFilter(
|
|
41
|
+
# must_filter=ExportFilterOptions(name_contains="Test Export")
|
|
42
|
+
# )
|
|
43
|
+
# exports, next_cursor, total_count = export_service.get_exports(
|
|
44
|
+
# dataset_id=dataset_id,
|
|
45
|
+
# export_filter=export_filter,
|
|
46
|
+
# length=10
|
|
47
|
+
# )
|
|
48
|
+
# print(f"Found {len(exports)} exports, total: {total_count}")
|
|
49
|
+
|
|
50
|
+
# # 3. Get a specific export
|
|
51
|
+
# if exports:
|
|
52
|
+
# export_detail = export_service.get_export(
|
|
53
|
+
# dataset_id=dataset_id,
|
|
54
|
+
# export_id=exports[0].id
|
|
55
|
+
# )
|
|
56
|
+
# print(f"Export details: {export_detail.name}")
|
|
57
|
+
|
|
58
|
+
# # 4. Update the export
|
|
59
|
+
# updated_export = export_service.update_export(
|
|
60
|
+
# dataset_id=dataset_id,
|
|
61
|
+
# export_id=new_export.id,
|
|
62
|
+
# name="Updated Test Export",
|
|
63
|
+
# meta={"updated_by": "integration_test", "status": "updated"}
|
|
64
|
+
# )
|
|
65
|
+
# print(f"Updated export name: {updated_export.name}")
|
|
66
|
+
|
|
67
|
+
# # 5. Delete the export
|
|
68
|
+
# delete_result = export_service.delete_export(
|
|
69
|
+
# dataset_id=dataset_id,
|
|
70
|
+
# export_id=new_export.id
|
|
71
|
+
# )
|
|
72
|
+
# print(f"Export deleted: {delete_result}")
|
|
73
|
+
|
|
74
|
+
# For now, just pass the test
|
|
75
|
+
assert True
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_export_filtering_examples():
|
|
79
|
+
"""
|
|
80
|
+
Examples of how to use export filtering.
|
|
81
|
+
"""
|
|
82
|
+
# Example 1: Filter by name containing specific text
|
|
83
|
+
name_filter = ExportFilter(
|
|
84
|
+
must_filter=ExportFilterOptions(name_contains="validation")
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Example 2: Filter by exact name match
|
|
88
|
+
exact_name_filter = ExportFilter(
|
|
89
|
+
must_filter=ExportFilterOptions(name="My Export")
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Example 3: Filter by location containing specific text
|
|
93
|
+
location_filter = ExportFilter(
|
|
94
|
+
must_filter=ExportFilterOptions(location_contains="s3://my-bucket")
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Example 4: Complex filter with must and must not conditions
|
|
98
|
+
complex_filter = ExportFilter(
|
|
99
|
+
must_filter=ExportFilterOptions(
|
|
100
|
+
name_contains="production",
|
|
101
|
+
location_contains="s3://"
|
|
102
|
+
),
|
|
103
|
+
not_filter=ExportFilterOptions(
|
|
104
|
+
name_contains="test"
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Example 5: Filter by multiple IDs
|
|
109
|
+
id_filter = ExportFilter(
|
|
110
|
+
must_filter=ExportFilterOptions(
|
|
111
|
+
id_in=["export_id_1", "export_id_2", "export_id_3"]
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# All filters should be valid - test the objects themselves
|
|
116
|
+
assert isinstance(name_filter.must_filter, ExportFilterOptions)
|
|
117
|
+
assert isinstance(exact_name_filter.must_filter, ExportFilterOptions)
|
|
118
|
+
assert isinstance(location_filter.must_filter, ExportFilterOptions)
|
|
119
|
+
assert isinstance(complex_filter.must_filter, ExportFilterOptions)
|
|
120
|
+
assert isinstance(complex_filter.not_filter, ExportFilterOptions)
|
|
121
|
+
assert isinstance(id_filter.must_filter, ExportFilterOptions)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_export_service_usage_patterns():
|
|
125
|
+
"""
|
|
126
|
+
Demonstrates common usage patterns for the export service.
|
|
127
|
+
"""
|
|
128
|
+
# Pattern 1: Pagination through all exports
|
|
129
|
+
def get_all_exports(export_service, dataset_id):
|
|
130
|
+
all_exports = []
|
|
131
|
+
cursor = None
|
|
132
|
+
|
|
133
|
+
while True:
|
|
134
|
+
exports, next_cursor, _ = export_service.get_exports(
|
|
135
|
+
dataset_id=dataset_id,
|
|
136
|
+
cursor=cursor,
|
|
137
|
+
length=50 # Fetch 50 at a time
|
|
138
|
+
)
|
|
139
|
+
all_exports.extend(exports)
|
|
140
|
+
|
|
141
|
+
if next_cursor is None:
|
|
142
|
+
break
|
|
143
|
+
cursor = next_cursor
|
|
144
|
+
|
|
145
|
+
return all_exports
|
|
146
|
+
|
|
147
|
+
# Pattern 2: Find exports by criteria
|
|
148
|
+
def find_exports_by_name(export_service, dataset_id, name_pattern):
|
|
149
|
+
filter_options = ExportFilter(
|
|
150
|
+
must_filter=ExportFilterOptions(name_contains=name_pattern)
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
exports, _, _ = export_service.get_exports(
|
|
154
|
+
dataset_id=dataset_id,
|
|
155
|
+
export_filter=filter_options,
|
|
156
|
+
length=100
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
return exports
|
|
160
|
+
|
|
161
|
+
# Pattern 3: Bulk operations
|
|
162
|
+
def cleanup_test_exports(export_service, dataset_id):
|
|
163
|
+
test_filter = ExportFilter(
|
|
164
|
+
must_filter=ExportFilterOptions(name_contains="test")
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
exports, _, _ = export_service.get_exports(
|
|
168
|
+
dataset_id=dataset_id,
|
|
169
|
+
export_filter=test_filter,
|
|
170
|
+
length=100
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
deleted_count = 0
|
|
174
|
+
for export in exports:
|
|
175
|
+
if export_service.delete_export(dataset_id, export.id):
|
|
176
|
+
deleted_count += 1
|
|
177
|
+
|
|
178
|
+
return deleted_count
|
|
179
|
+
|
|
180
|
+
# These are just example functions, so we'll just assert they exist
|
|
181
|
+
assert callable(get_all_exports)
|
|
182
|
+
assert callable(find_exports_by_name)
|
|
183
|
+
assert callable(cleanup_test_exports)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
if __name__ == "__main__":
|
|
187
|
+
# Run the integration test
|
|
188
|
+
test_export_service_integration()
|
|
189
|
+
test_export_filtering_examples()
|
|
190
|
+
test_export_service_usage_patterns()
|
|
191
|
+
print("All integration tests passed!")
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
from spb_onprem.exports.params.create_export import create_export_params
|
|
5
|
+
from spb_onprem.exports.params.update_export import update_export_params
|
|
6
|
+
from spb_onprem.exports.params.export import get_export_params
|
|
7
|
+
from spb_onprem.exports.params.delete_export import delete_export_params
|
|
8
|
+
from spb_onprem.exports.params.exports import get_exports_params, ExportFilter, ExportFilterOptions
|
|
9
|
+
from spb_onprem.exceptions import BadParameterError
|
|
10
|
+
from spb_onprem.base_types import Undefined
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TestCreateExportParams:
|
|
14
|
+
def test_create_export_params_minimal(self):
|
|
15
|
+
# Given
|
|
16
|
+
dataset_id = "test_dataset_id"
|
|
17
|
+
|
|
18
|
+
# When
|
|
19
|
+
params = create_export_params(dataset_id=dataset_id)
|
|
20
|
+
|
|
21
|
+
# Then
|
|
22
|
+
assert params["dataset_id"] == dataset_id
|
|
23
|
+
assert "location" not in params
|
|
24
|
+
assert "name" not in params
|
|
25
|
+
assert "data_filter" not in params
|
|
26
|
+
assert "meta" not in params
|
|
27
|
+
|
|
28
|
+
def test_create_export_params_full(self):
|
|
29
|
+
# Given
|
|
30
|
+
dataset_id = "test_dataset_id"
|
|
31
|
+
location = "s3://test-bucket/exports/"
|
|
32
|
+
name = "test_export"
|
|
33
|
+
data_filter = {"must": {"keyContains": "test"}}
|
|
34
|
+
data_count = 100
|
|
35
|
+
frame_count = 50
|
|
36
|
+
annotation_count = 25
|
|
37
|
+
meta = {"created_by": "test_user"}
|
|
38
|
+
|
|
39
|
+
# When
|
|
40
|
+
params = create_export_params(
|
|
41
|
+
dataset_id=dataset_id,
|
|
42
|
+
location=location,
|
|
43
|
+
name=name,
|
|
44
|
+
data_filter=data_filter,
|
|
45
|
+
data_count=data_count,
|
|
46
|
+
frame_count=frame_count,
|
|
47
|
+
annotation_count=annotation_count,
|
|
48
|
+
meta=meta
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Then
|
|
52
|
+
assert params["dataset_id"] == dataset_id
|
|
53
|
+
assert params["location"] == location
|
|
54
|
+
assert params["name"] == name
|
|
55
|
+
assert params["data_filter"] == data_filter
|
|
56
|
+
assert params["data_count"] == data_count
|
|
57
|
+
assert params["frame_count"] == frame_count
|
|
58
|
+
assert params["annotation_count"] == annotation_count
|
|
59
|
+
assert params["meta"] == meta
|
|
60
|
+
|
|
61
|
+
def test_create_export_params_missing_dataset_id(self):
|
|
62
|
+
# Given
|
|
63
|
+
dataset_id = None
|
|
64
|
+
|
|
65
|
+
# When/Then
|
|
66
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
67
|
+
create_export_params(dataset_id=dataset_id)
|
|
68
|
+
assert str(exc_info.value) == "Dataset ID is required"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class TestUpdateExportParams:
|
|
72
|
+
def test_update_export_params_minimal(self):
|
|
73
|
+
# Given
|
|
74
|
+
dataset_id = "test_dataset_id"
|
|
75
|
+
export_id = "test_export_id"
|
|
76
|
+
|
|
77
|
+
# When
|
|
78
|
+
params = update_export_params(
|
|
79
|
+
dataset_id=dataset_id,
|
|
80
|
+
export_id=export_id
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Then
|
|
84
|
+
assert params["dataset_id"] == dataset_id
|
|
85
|
+
assert params["export_id"] == export_id
|
|
86
|
+
assert "location" not in params
|
|
87
|
+
assert "name" not in params
|
|
88
|
+
assert "data_filter" not in params
|
|
89
|
+
assert "meta" not in params
|
|
90
|
+
|
|
91
|
+
def test_update_export_params_full(self):
|
|
92
|
+
# Given
|
|
93
|
+
dataset_id = "test_dataset_id"
|
|
94
|
+
export_id = "test_export_id"
|
|
95
|
+
location = "s3://test-bucket/updated/"
|
|
96
|
+
name = "updated_export"
|
|
97
|
+
data_filter = {"must": {"updated": True}}
|
|
98
|
+
data_count = 200
|
|
99
|
+
frame_count = 100
|
|
100
|
+
annotation_count = 50
|
|
101
|
+
meta = {"updated_by": "test_user"}
|
|
102
|
+
completed_at = datetime(2024, 1, 1, 12, 0, 0)
|
|
103
|
+
|
|
104
|
+
# When
|
|
105
|
+
params = update_export_params(
|
|
106
|
+
dataset_id=dataset_id,
|
|
107
|
+
export_id=export_id,
|
|
108
|
+
location=location,
|
|
109
|
+
name=name,
|
|
110
|
+
data_filter=data_filter,
|
|
111
|
+
data_count=data_count,
|
|
112
|
+
frame_count=frame_count,
|
|
113
|
+
annotation_count=annotation_count,
|
|
114
|
+
meta=meta,
|
|
115
|
+
completed_at=completed_at
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# Then
|
|
119
|
+
assert params["dataset_id"] == dataset_id
|
|
120
|
+
assert params["export_id"] == export_id
|
|
121
|
+
assert params["location"] == location
|
|
122
|
+
assert params["name"] == name
|
|
123
|
+
assert params["data_filter"] == data_filter
|
|
124
|
+
assert params["data_count"] == data_count
|
|
125
|
+
assert params["frame_count"] == frame_count
|
|
126
|
+
assert params["annotation_count"] == annotation_count
|
|
127
|
+
assert params["meta"] == meta
|
|
128
|
+
assert params["completed_at"] == completed_at
|
|
129
|
+
|
|
130
|
+
def test_update_export_params_missing_dataset_id(self):
|
|
131
|
+
# Given
|
|
132
|
+
dataset_id = None
|
|
133
|
+
export_id = "test_export_id"
|
|
134
|
+
|
|
135
|
+
# When/Then
|
|
136
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
137
|
+
update_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
138
|
+
assert str(exc_info.value) == "Dataset ID is required"
|
|
139
|
+
|
|
140
|
+
def test_update_export_params_missing_export_id(self):
|
|
141
|
+
# Given
|
|
142
|
+
dataset_id = "test_dataset_id"
|
|
143
|
+
export_id = None
|
|
144
|
+
|
|
145
|
+
# When/Then
|
|
146
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
147
|
+
update_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
148
|
+
assert str(exc_info.value) == "Export ID is required"
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class TestGetExportParams:
|
|
152
|
+
def test_get_export_params(self):
|
|
153
|
+
# Given
|
|
154
|
+
dataset_id = "test_dataset_id"
|
|
155
|
+
export_id = "test_export_id"
|
|
156
|
+
|
|
157
|
+
# When
|
|
158
|
+
params = get_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
159
|
+
|
|
160
|
+
# Then
|
|
161
|
+
assert params["dataset_id"] == dataset_id
|
|
162
|
+
assert params["export_id"] == export_id
|
|
163
|
+
|
|
164
|
+
def test_get_export_params_missing_dataset_id(self):
|
|
165
|
+
# Given
|
|
166
|
+
dataset_id = None
|
|
167
|
+
export_id = "test_export_id"
|
|
168
|
+
|
|
169
|
+
# When/Then
|
|
170
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
171
|
+
get_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
172
|
+
assert str(exc_info.value) == "Dataset ID is required"
|
|
173
|
+
|
|
174
|
+
def test_get_export_params_missing_export_id(self):
|
|
175
|
+
# Given
|
|
176
|
+
dataset_id = "test_dataset_id"
|
|
177
|
+
export_id = None
|
|
178
|
+
|
|
179
|
+
# When/Then
|
|
180
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
181
|
+
get_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
182
|
+
assert str(exc_info.value) == "Export ID is required"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class TestDeleteExportParams:
|
|
186
|
+
def test_delete_export_params(self):
|
|
187
|
+
# Given
|
|
188
|
+
dataset_id = "test_dataset_id"
|
|
189
|
+
export_id = "test_export_id"
|
|
190
|
+
|
|
191
|
+
# When
|
|
192
|
+
params = delete_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
193
|
+
|
|
194
|
+
# Then
|
|
195
|
+
assert params["dataset_id"] == dataset_id
|
|
196
|
+
assert params["export_id"] == export_id
|
|
197
|
+
|
|
198
|
+
def test_delete_export_params_missing_dataset_id(self):
|
|
199
|
+
# Given
|
|
200
|
+
dataset_id = None
|
|
201
|
+
export_id = "test_export_id"
|
|
202
|
+
|
|
203
|
+
# When/Then
|
|
204
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
205
|
+
delete_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
206
|
+
assert str(exc_info.value) == "Dataset ID is required"
|
|
207
|
+
|
|
208
|
+
def test_delete_export_params_missing_export_id(self):
|
|
209
|
+
# Given
|
|
210
|
+
dataset_id = "test_dataset_id"
|
|
211
|
+
export_id = None
|
|
212
|
+
|
|
213
|
+
# When/Then
|
|
214
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
215
|
+
delete_export_params(dataset_id=dataset_id, export_id=export_id)
|
|
216
|
+
assert str(exc_info.value) == "Export ID is required"
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class TestGetExportsParams:
|
|
220
|
+
def test_get_exports_params_minimal(self):
|
|
221
|
+
# Given
|
|
222
|
+
dataset_id = "test_dataset_id"
|
|
223
|
+
|
|
224
|
+
# When
|
|
225
|
+
params = get_exports_params(dataset_id=dataset_id)
|
|
226
|
+
|
|
227
|
+
# Then
|
|
228
|
+
assert params["dataset_id"] == dataset_id
|
|
229
|
+
assert params["length"] == 10
|
|
230
|
+
assert "filter" not in params
|
|
231
|
+
assert "cursor" not in params
|
|
232
|
+
|
|
233
|
+
def test_get_exports_params_with_filter(self):
|
|
234
|
+
# Given
|
|
235
|
+
dataset_id = "test_dataset_id"
|
|
236
|
+
export_filter = ExportFilter(
|
|
237
|
+
must_filter=ExportFilterOptions(name="test_export"),
|
|
238
|
+
not_filter=ExportFilterOptions(location_contains="temp")
|
|
239
|
+
)
|
|
240
|
+
cursor = "test_cursor"
|
|
241
|
+
length = 20
|
|
242
|
+
|
|
243
|
+
# When
|
|
244
|
+
params = get_exports_params(
|
|
245
|
+
dataset_id=dataset_id,
|
|
246
|
+
export_filter=export_filter,
|
|
247
|
+
cursor=cursor,
|
|
248
|
+
length=length
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
# Then
|
|
252
|
+
assert params["dataset_id"] == dataset_id
|
|
253
|
+
assert params["length"] == length
|
|
254
|
+
assert params["cursor"] == cursor
|
|
255
|
+
assert "filter" in params
|
|
256
|
+
assert params["filter"]["must"]["name"] == "test_export"
|
|
257
|
+
assert params["filter"]["not"]["locationContains"] == "temp"
|
|
258
|
+
|
|
259
|
+
def test_get_exports_params_missing_dataset_id(self):
|
|
260
|
+
# Given
|
|
261
|
+
dataset_id = None
|
|
262
|
+
|
|
263
|
+
# When/Then
|
|
264
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
265
|
+
get_exports_params(dataset_id=dataset_id)
|
|
266
|
+
assert str(exc_info.value) == "Dataset ID is required"
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
class TestExportFilterOptions:
|
|
270
|
+
def test_export_filter_options_creation(self):
|
|
271
|
+
# Given/When
|
|
272
|
+
filter_options = ExportFilterOptions(
|
|
273
|
+
id_in=["id1", "id2"],
|
|
274
|
+
name_contains="test",
|
|
275
|
+
name="exact_name",
|
|
276
|
+
location_contains="bucket",
|
|
277
|
+
location="s3://test-bucket/"
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
# Then
|
|
281
|
+
assert filter_options.id_in == ["id1", "id2"]
|
|
282
|
+
assert filter_options.name_contains == "test"
|
|
283
|
+
assert filter_options.name == "exact_name"
|
|
284
|
+
assert filter_options.location_contains == "bucket"
|
|
285
|
+
assert filter_options.location == "s3://test-bucket/"
|
|
286
|
+
|
|
287
|
+
def test_export_filter_options_aliases(self):
|
|
288
|
+
# Given/When
|
|
289
|
+
filter_options = ExportFilterOptions(
|
|
290
|
+
id_in=["id1", "id2"],
|
|
291
|
+
name_contains="test"
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
# Then
|
|
295
|
+
dumped = filter_options.model_dump(by_alias=True)
|
|
296
|
+
assert dumped["idIn"] == ["id1", "id2"]
|
|
297
|
+
assert dumped["nameContains"] == "test"
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class TestExportFilter:
|
|
301
|
+
def test_export_filter_creation(self):
|
|
302
|
+
# Given
|
|
303
|
+
must_filter = ExportFilterOptions(name="test_export")
|
|
304
|
+
not_filter = ExportFilterOptions(location_contains="temp")
|
|
305
|
+
|
|
306
|
+
# When
|
|
307
|
+
export_filter = ExportFilter(
|
|
308
|
+
must_filter=must_filter,
|
|
309
|
+
not_filter=not_filter
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
# Then
|
|
313
|
+
assert export_filter.must_filter == must_filter
|
|
314
|
+
assert export_filter.not_filter == not_filter
|
|
315
|
+
|
|
316
|
+
def test_export_filter_aliases(self):
|
|
317
|
+
# Given
|
|
318
|
+
must_filter = ExportFilterOptions(name="test_export")
|
|
319
|
+
not_filter = ExportFilterOptions(location_contains="temp")
|
|
320
|
+
export_filter = ExportFilter(
|
|
321
|
+
must_filter=must_filter,
|
|
322
|
+
not_filter=not_filter
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
# When
|
|
326
|
+
dumped = export_filter.model_dump(by_alias=True, exclude_unset=True)
|
|
327
|
+
|
|
328
|
+
# Then
|
|
329
|
+
assert "must" in dumped
|
|
330
|
+
assert "not" in dumped
|
|
331
|
+
assert dumped["must"]["name"] == "test_export"
|
|
332
|
+
assert dumped["not"]["locationContains"] == "temp"
|