@@ -198,3 +198,67 @@ def test_private_query_fail_on_second():
198
198
city_name = "西東京市" ,
199
199
)
200
200
assert result is None
201
+
202
+ @httpretty .activate (verbose = True , allow_net_connect = False )
203
+ def test_asset_upload ():
204
+ from plateauutils .citygmlfinder .from_reearth_cms import upload_to_reearth
205
+
206
+ data = """{
207
+ "archiveExtractionStatus": "done",
208
+ "contentType": "text/plain; charset=utf-8",
209
+ "createdAt": "2023-09-29T08:58:10.712Z",
210
+ "file": {
211
+ "contentType": "text/plain; charset=utf-8",
212
+ "name": "sample.txt",
213
+ "path": "/sample.txt",
214
+ "size": 13
215
+ },
216
+ "id": "01hbg2hrwr1qvx6prdxsf44x1z",
217
+ "name": "sample.txt",
218
+ "previewType": "unknown",
219
+ "projectId": "01h2f43g1w67as5meqvbh4xas6",
220
+ "totalSize": 13,
221
+ "updatedAt": "0001-01-01T00:00:00Z",
222
+ "url": "http://localhost:8080/assets/assets/6b/665c61-9168-4a30-b9c4-5ee88be7f71a/sample.txt"
223
+ }"""
224
+ httpretty .register_uri (
225
+ httpretty .POST ,
226
+ "http://localhost:8081/api/projects/dummy/assets" ,
227
+ body = data ,
228
+ content_type = "application/json" ,
229
+ )
230
+ result = upload_to_reearth (
231
+ endpoint = "http://localhost:8081/api" ,
232
+ access_token = "dummy" ,
233
+ project = "dummy" ,
234
+ filepath = "./plateauutils/citygmlfinder/tests/data1.json"
235
+ )
236
+ assert (
237
+ result
238
+ == True
239
+ )
240
+
241
+ @httpretty .activate (verbose = True , allow_net_connect = False )
242
+ def test_asset_upload_fail ():
243
+ from plateauutils .citygmlfinder .from_reearth_cms import upload_to_reearth
244
+
245
+ data = """{
246
+ "error": "operation denied"
247
+ }"""
248
+ httpretty .register_uri (
249
+ httpretty .POST ,
250
+ "http://localhost:8081/api/projects/dummy/assets" ,
251
+ status = 400 ,
252
+ body = data ,
253
+ content_type = "application/json" ,
254
+ )
255
+ result = upload_to_reearth (
256
+ endpoint = "http://localhost:8081/api" ,
257
+ access_token = "dummy" ,
258
+ project = "dummy" ,
259
+ filepath = "./plateauutils/citygmlfinder/tests/data1.json"
260
+ )
261
+ assert (
262
+ result
263
+ == False
264
+ )
0 commit comments