| @@ 393-446 (lines=54) @@ | ||
| 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 | """ |
|
| 395 | Update(put) one folder content |
|
| 396 | """ |
|
| 397 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 398 | admin = dbsession.query(models.User) \ |
|
| 399 | .filter(models.User.email == '[email protected]') \ |
|
| 400 | .one() |
|
| 401 | workspace_api = WorkspaceApi( |
|
| 402 | current_user=admin, |
|
| 403 | session=dbsession, |
|
| 404 | config=self.app_config |
|
| 405 | ) |
|
| 406 | content_api = ContentApi( |
|
| 407 | current_user=admin, |
|
| 408 | session=dbsession, |
|
| 409 | config=self.app_config |
|
| 410 | ) |
|
| 411 | test_workspace = workspace_api.create_workspace( |
|
| 412 | label='test', |
|
| 413 | save_now=True, |
|
| 414 | ) |
|
| 415 | folder = content_api.create( |
|
| 416 | label='test_folder', |
|
| 417 | content_type_slug=content_type_list.Folder.slug, |
|
| 418 | workspace=test_workspace, |
|
| 419 | do_save=True, |
|
| 420 | do_notify=False |
|
| 421 | ) |
|
| 422 | transaction.commit() |
|
| 423 | self.testapp.authorization = ( |
|
| 424 | 'Basic', |
|
| 425 | ( |
|
| 426 | '[email protected]', |
|
| 427 | '[email protected]' |
|
| 428 | ) |
|
| 429 | ) |
|
| 430 | params = { |
|
| 431 | 'label': '', |
|
| 432 | 'raw_content': '<p> Le nouveau contenu </p>', |
|
| 433 | 'sub_content_types': [content_type_list.Folder.slug] |
|
| 434 | } |
|
| 435 | res = self.testapp.put_json( |
|
| 436 | '/api/v2/workspaces/{workspace_id}/folders/{content_id}'.format( |
|
| 437 | workspace_id=test_workspace.workspace_id, |
|
| 438 | content_id=folder.content_id, |
|
| 439 | ), |
|
| 440 | params=params, |
|
| 441 | status=400 |
|
| 442 | ) |
|
| 443 | # INFO - G.M - 2018-09-10 - Handled by marshmallow schema |
|
| 444 | assert res.json_body |
|
| 445 | assert 'code' in res.json_body |
|
| 446 | assert res.json_body['code'] == error.GENERIC_SCHEMA_VALIDATION_ERROR # nopep8 |
|
| 447 | ||
| 448 | def test_api__update_folder__ok_200__nominal_case(self) -> None: |
|
| 449 | """ |
|
| @@ 924-975 (lines=52) @@ | ||
| 921 | assert content['content_id'] == folder.content_id |
|
| 922 | assert content['status'] == 'closed-deprecated' |
|
| 923 | ||
| 924 | def test_api__set_folder_status__err_400__wrong_status(self) -> None: |
|
| 925 | """ |
|
| 926 | Get one folder content |
|
| 927 | """ |
|
| 928 | self.testapp.authorization = ( |
|
| 929 | 'Basic', |
|
| 930 | ( |
|
| 931 | '[email protected]', |
|
| 932 | '[email protected]' |
|
| 933 | ) |
|
| 934 | ) |
|
| 935 | params = { |
|
| 936 | 'status': 'unexistant-status', |
|
| 937 | } |
|
| 938 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 939 | admin = dbsession.query(models.User) \ |
|
| 940 | .filter(models.User.email == '[email protected]') \ |
|
| 941 | .one() |
|
| 942 | workspace_api = WorkspaceApi( |
|
| 943 | current_user=admin, |
|
| 944 | session=dbsession, |
|
| 945 | config=self.app_config |
|
| 946 | ) |
|
| 947 | content_api = ContentApi( |
|
| 948 | current_user=admin, |
|
| 949 | session=dbsession, |
|
| 950 | config=self.app_config |
|
| 951 | ) |
|
| 952 | test_workspace = workspace_api.create_workspace( |
|
| 953 | label='test', |
|
| 954 | save_now=True, |
|
| 955 | ) |
|
| 956 | folder = content_api.create( |
|
| 957 | label='test_folder', |
|
| 958 | content_type_slug=content_type_list.Folder.slug, |
|
| 959 | workspace=test_workspace, |
|
| 960 | do_save=True, |
|
| 961 | do_notify=False |
|
| 962 | ) |
|
| 963 | transaction.commit() |
|
| 964 | res = self.testapp.put_json( |
|
| 965 | '/api/v2/workspaces/{workspace_id}/folders/{content_id}/status'.format( # nopep8 |
|
| 966 | workspace_id=test_workspace.workspace_id, |
|
| 967 | content_id=folder.content_id, |
|
| 968 | ), |
|
| 969 | params=params, |
|
| 970 | status=400 |
|
| 971 | ) |
|
| 972 | # TODO - G.M - 2018-09-10 - handle by marshmallow schema |
|
| 973 | assert res.json_body |
|
| 974 | assert 'code' in res.json_body |
|
| 975 | assert res.json_body['code'] == error.GENERIC_SCHEMA_VALIDATION_ERROR # nopep8 |
|
| 976 | ||
| 977 | ||
| 978 | class TestHtmlDocuments(FunctionalTest): |
|