@@ 347-391 (lines=45) @@ | ||
344 | assert 'code' in res.json_body |
|
345 | assert res.json_body['code'] == error.WORKSPACE_INVALID_ID |
|
346 | ||
347 | def test_api__get_folder__err_400__content_id_is_not_int(self) -> None: # nopep8 |
|
348 | """ |
|
349 | Get one folder content, content_id is not int |
|
350 | """ |
|
351 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
352 | admin = dbsession.query(models.User) \ |
|
353 | .filter(models.User.email == '[email protected]') \ |
|
354 | .one() |
|
355 | workspace_api = WorkspaceApi( |
|
356 | current_user=admin, |
|
357 | session=dbsession, |
|
358 | config=self.app_config |
|
359 | ) |
|
360 | content_api = ContentApi( |
|
361 | current_user=admin, |
|
362 | session=dbsession, |
|
363 | config=self.app_config |
|
364 | ) |
|
365 | test_workspace = workspace_api.create_workspace( |
|
366 | label='test', |
|
367 | save_now=True, |
|
368 | ) |
|
369 | folder = content_api.create( |
|
370 | label='test_folder', |
|
371 | content_type_slug=content_type_list.Folder.slug, |
|
372 | workspace=test_workspace, |
|
373 | do_save=True, |
|
374 | do_notify=False |
|
375 | ) |
|
376 | transaction.commit() |
|
377 | ||
378 | self.testapp.authorization = ( |
|
379 | 'Basic', |
|
380 | ( |
|
381 | '[email protected]', |
|
382 | '[email protected]' |
|
383 | ) |
|
384 | ) |
|
385 | res = self.testapp.get( |
|
386 | '/api/v2/workspaces/{workspace_id}/folders/coucou'.format(workspace_id=test_workspace.workspace_id), # nopep8 |
|
387 | status=400 |
|
388 | ) |
|
389 | assert res.json_body |
|
390 | assert 'code' in res.json_body |
|
391 | assert res.json_body['code'] == error.CONTENT_INVALID_ID |
|
392 | ||
393 | def test_api__update_folder__err_400__empty_label(self) -> None: # nopep8 |
|
394 | """ |
|
@@ 302-345 (lines=44) @@ | ||
299 | assert 'code' in res.json_body |
|
300 | assert res.json_body['code'] == error.WORKSPACE_NOT_FOUND |
|
301 | ||
302 | def test_api__get_folder__err_400__workspace_id_is_not_int(self) -> None: # nopep8 |
|
303 | """ |
|
304 | Get one folder content, workspace id is not int |
|
305 | """ |
|
306 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
307 | admin = dbsession.query(models.User) \ |
|
308 | .filter(models.User.email == '[email protected]') \ |
|
309 | .one() |
|
310 | workspace_api = WorkspaceApi( |
|
311 | current_user=admin, |
|
312 | session=dbsession, |
|
313 | config=self.app_config |
|
314 | ) |
|
315 | content_api = ContentApi( |
|
316 | current_user=admin, |
|
317 | session=dbsession, |
|
318 | config=self.app_config |
|
319 | ) |
|
320 | test_workspace = workspace_api.create_workspace( |
|
321 | label='test', |
|
322 | save_now=True, |
|
323 | ) |
|
324 | folder = content_api.create( |
|
325 | label='test_folder', |
|
326 | content_type_slug=content_type_list.Folder.slug, |
|
327 | workspace=test_workspace, |
|
328 | do_save=True, |
|
329 | do_notify=False |
|
330 | ) |
|
331 | transaction.commit() |
|
332 | self.testapp.authorization = ( |
|
333 | 'Basic', |
|
334 | ( |
|
335 | '[email protected]', |
|
336 | '[email protected]' |
|
337 | ) |
|
338 | ) |
|
339 | res = self.testapp.get( |
|
340 | '/api/v2/workspaces/coucou/folders/{content_id}'.format(content_id=folder.content_id), # nopep8 |
|
341 | status=400 |
|
342 | ) |
|
343 | assert res.json_body |
|
344 | assert 'code' in res.json_body |
|
345 | assert res.json_body['code'] == error.WORKSPACE_INVALID_ID |
|
346 | ||
347 | def test_api__get_folder__err_400__content_id_is_not_int(self) -> None: # nopep8 |
|
348 | """ |
|
@@ 257-300 (lines=44) @@ | ||
254 | assert 'code' in res.json_body |
|
255 | assert res.json_body['code'] == error.CONTENT_NOT_FOUND |
|
256 | ||
257 | def test_api__get_folder__err_400__workspace_does_not_exist(self) -> None: # nopep8 |
|
258 | """ |
|
259 | Get one folder content (Workspace 40 does not exist) |
|
260 | """ |
|
261 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
262 | admin = dbsession.query(models.User) \ |
|
263 | .filter(models.User.email == '[email protected]') \ |
|
264 | .one() |
|
265 | workspace_api = WorkspaceApi( |
|
266 | current_user=admin, |
|
267 | session=dbsession, |
|
268 | config=self.app_config |
|
269 | ) |
|
270 | content_api = ContentApi( |
|
271 | current_user=admin, |
|
272 | session=dbsession, |
|
273 | config=self.app_config |
|
274 | ) |
|
275 | test_workspace = workspace_api.create_workspace( |
|
276 | label='test', |
|
277 | save_now=True, |
|
278 | ) |
|
279 | folder = content_api.create( |
|
280 | label='test_folder', |
|
281 | content_type_slug=content_type_list.Folder.slug, |
|
282 | workspace=test_workspace, |
|
283 | do_save=True, |
|
284 | do_notify=False |
|
285 | ) |
|
286 | transaction.commit() |
|
287 | self.testapp.authorization = ( |
|
288 | 'Basic', |
|
289 | ( |
|
290 | '[email protected]', |
|
291 | '[email protected]' |
|
292 | ) |
|
293 | ) |
|
294 | res = self.testapp.get( |
|
295 | '/api/v2/workspaces/40/folders/{content_id}'.format(content_id=folder.content_id), # nopep8 |
|
296 | status=400 |
|
297 | ) |
|
298 | assert res.json_body |
|
299 | assert 'code' in res.json_body |
|
300 | assert res.json_body['code'] == error.WORKSPACE_NOT_FOUND |
|
301 | ||
302 | def test_api__get_folder__err_400__workspace_id_is_not_int(self) -> None: # nopep8 |
|
303 | """ |