@@ -18,14 +18,11 @@ def test_add_metadata_adds_to_existing_metadata(mocker: pytest_mock.MockerFixtur
1818 existing_assets = [
1919 {
2020 "id" : "asset1" ,
21- "jsonMetadata" : {"text" : "Some text" , "assetLabelingMetadata" : { " existing1" : "value1" } },
21+ "jsonMetadata" : {"text" : "Some text" , "existing1" : "value1" },
2222 },
2323 {
2424 "id" : "asset2" ,
25- "jsonMetadata" : {
26- "imageUrl" : "http://example.com/image.jpg" ,
27- "assetLabelingMetadata" : {"existing2" : "value2" },
28- },
25+ "jsonMetadata" : {"imageUrl" : "http://example.com/image.jpg" , "existing2" : "value2" },
2926 },
3027 ]
3128
@@ -46,7 +43,7 @@ def test_add_metadata_adds_to_existing_metadata(mocker: pytest_mock.MockerFixtur
4643 ]
4744
4845 result = mutations_asset .add_metadata (
49- asset_labeling_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
46+ json_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
5047 )
5148
5249 kili_api_gateway .list_assets .assert_called_once_with (
@@ -61,13 +58,11 @@ def test_add_metadata_adds_to_existing_metadata(mocker: pytest_mock.MockerFixtur
6158 assert call_args ["asset_ids" ] == asset_ids
6259
6360 expected_metadata = [
64- {
65- "text" : "Some text" ,
66- "assetLabelingMetadata" : {"existing1" : "value1" , "new_key1" : "new_value1" },
67- },
61+ {"text" : "Some text" , "existing1" : "value1" , "new_key1" : "new_value1" },
6862 {
6963 "imageUrl" : "http://example.com/image.jpg" ,
70- "assetLabelingMetadata" : {"existing2" : "value2" , "new_key2" : "new_value2" },
64+ "existing2" : "value2" ,
65+ "new_key2" : "new_value2" ,
7166 },
7267 ]
7368
@@ -82,16 +77,14 @@ def test_set_metadata_replaces_existing_metadata(mocker: pytest_mock.MockerFixtu
8277 existing_assets = [
8378 {
8479 "id" : "asset1" ,
85- "jsonMetadata" : {
86- "text" : "Some text" ,
87- "assetLabelingMetadata" : {"existing1" : "value1" , "should_be_removed" : True },
88- },
80+ "jsonMetadata" : {"text" : "Some text" , "existing1" : "value1" , "should_be_removed" : True },
8981 },
9082 {
9183 "id" : "asset2" ,
9284 "jsonMetadata" : {
9385 "imageUrl" : "http://example.com/image.jpg" ,
94- "assetLabelingMetadata" : {"existing2" : "value2" , "also_remove" : "yes" },
86+ "existing2" : "value2" ,
87+ "also_remove" : "yes" ,
9588 },
9689 },
9790 ]
@@ -113,7 +106,7 @@ def test_set_metadata_replaces_existing_metadata(mocker: pytest_mock.MockerFixtu
113106 ]
114107
115108 result = mutations_asset .set_metadata (
116- asset_labeling_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
109+ json_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
117110 )
118111
119112 kili_api_gateway .list_assets .assert_called_once_with (
@@ -128,11 +121,8 @@ def test_set_metadata_replaces_existing_metadata(mocker: pytest_mock.MockerFixtu
128121 assert call_args ["asset_ids" ] == asset_ids
129122
130123 expected_metadata = [
131- {"text" : "Some text" , "assetLabelingMetadata" : {"new_key1" : "new_value1" }},
132- {
133- "imageUrl" : "http://example.com/image.jpg" ,
134- "assetLabelingMetadata" : {"new_key2" : "new_value2" },
135- },
124+ {"text" : "Some text" , "new_key1" : "new_value1" },
125+ {"imageUrl" : "http://example.com/image.jpg" , "new_key2" : "new_value2" },
136126 ]
137127
138128 assert call_args ["json_metadatas" ] == expected_metadata
@@ -162,14 +152,14 @@ def test_add_metadata_handles_missing_metadata(mocker: pytest_mock.MockerFixture
162152 ]
163153
164154 mutations_asset .add_metadata (
165- asset_labeling_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
155+ json_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
166156 )
167157
168158 call_args = update_mock .call_args [1 ]
169159
170160 expected_metadata = [
171- {"assetLabelingMetadata" : { " new_key1" : "new_value1" } },
172- {"assetLabelingMetadata" : { " new_key2" : "new_value2" } },
161+ {"new_key1" : "new_value1" },
162+ {"new_key2" : "new_value2" },
173163 ]
174164
175165 assert call_args ["json_metadatas" ] == expected_metadata
@@ -185,11 +175,10 @@ def test_multiple_assets_with_different_metadata_structures(mocker: pytest_mock.
185175 "id" : "asset2" ,
186176 "jsonMetadata" : {
187177 "imageUrl" : "http://example.com/image.jpg" ,
188- "assetLabelingMetadata" : {},
189178 },
190179 },
191180 {"id" : "asset3" , "jsonMetadata" : None },
192- {"id" : "asset4" , "jsonMetadata" : {"assetLabelingMetadata" : { " existing4" : "value4" } }},
181+ {"id" : "asset4" , "jsonMetadata" : {"existing4" : "value4" }},
193182 ]
194183
195184 kili_api_gateway .list_assets .return_value = existing_assets
@@ -211,31 +200,31 @@ def test_multiple_assets_with_different_metadata_structures(mocker: pytest_mock.
211200 ]
212201
213202 mutations_asset .add_metadata (
214- asset_labeling_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
203+ json_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
215204 )
216205
217206 add_metadata_call_args = update_mock .call_args [1 ]
218207
219208 update_mock .reset_mock ()
220209
221210 mutations_asset .set_metadata (
222- asset_labeling_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
211+ json_metadata = new_metadata , asset_ids = asset_ids , project_id = project_id
223212 )
224213
225214 set_metadata_call_args = update_mock .call_args [1 ]
226215
227216 expected_add_metadata = [
228- {"text" : "Text 1" , "assetLabelingMetadata" : { " meta1" : "value1" } },
229- {"imageUrl" : "http://example.com/image.jpg" , "assetLabelingMetadata" : { " meta2" : "value2" } },
230- {"assetLabelingMetadata" : { " meta3" : "value3" } },
231- {"assetLabelingMetadata" : { " existing4" : "value4" , "meta4" : "value4" } },
217+ {"text" : "Text 1" , "meta1" : "value1" },
218+ {"imageUrl" : "http://example.com/image.jpg" , "meta2" : "value2" },
219+ {"meta3" : "value3" },
220+ {"existing4" : "value4" , "meta4" : "value4" },
232221 ]
233222
234223 expected_set_metadata = [
235- {"text" : "Text 1" , "assetLabelingMetadata" : { " meta1" : "value1" } },
236- {"imageUrl" : "http://example.com/image.jpg" , "assetLabelingMetadata" : { " meta2" : "value2" } },
237- {"assetLabelingMetadata" : { " meta3" : "value3" } },
238- {"assetLabelingMetadata" : { " meta4" : "value4" } },
224+ {"text" : "Text 1" , "meta1" : "value1" },
225+ {"imageUrl" : "http://example.com/image.jpg" , "meta2" : "value2" },
226+ {"meta3" : "value3" },
227+ {"meta4" : "value4" },
239228 ]
240229
241230 assert add_metadata_call_args ["json_metadatas" ] == expected_add_metadata
0 commit comments