| @@ 2829-2870 (lines=42) @@ | ||
| 2826 | """ |
|
| 2827 | fixtures = [BaseFixture, ContentFixtures] |
|
| 2828 | ||
| 2829 | def test_api__get_user_workspaces__ok_200__nominal_case(self): |
|
| 2830 | """ |
|
| 2831 | Check obtain all workspaces reachables for user with user auth. |
|
| 2832 | """ |
|
| 2833 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 2834 | admin = dbsession.query(models.User) \ |
|
| 2835 | .filter(models.User.email == '[email protected]') \ |
|
| 2836 | .one() |
|
| 2837 | ||
| 2838 | workspace_api = WorkspaceApi( |
|
| 2839 | session=dbsession, |
|
| 2840 | current_user=admin, |
|
| 2841 | config=self.app_config, |
|
| 2842 | ) |
|
| 2843 | workspace = workspace_api.get_one(1) |
|
| 2844 | app_api = ApplicationApi( |
|
| 2845 | app_list |
|
| 2846 | ) |
|
| 2847 | ||
| 2848 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 2849 | self.testapp.authorization = ( |
|
| 2850 | 'Basic', |
|
| 2851 | ( |
|
| 2852 | '[email protected]', |
|
| 2853 | '[email protected]' |
|
| 2854 | ) |
|
| 2855 | ) |
|
| 2856 | res = self.testapp.get('/api/v2/users/1/workspaces', status=200) |
|
| 2857 | res = res.json_body |
|
| 2858 | workspace = res[0] |
|
| 2859 | assert workspace['workspace_id'] == 1 |
|
| 2860 | assert workspace['label'] == 'Business' |
|
| 2861 | assert workspace['slug'] == 'business' |
|
| 2862 | assert workspace['is_deleted'] is False |
|
| 2863 | ||
| 2864 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 2865 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 2866 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 2867 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 2868 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 2869 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 2870 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 2871 | ||
| 2872 | def test_api__get_user_workspaces__err_403__unallowed_user(self): |
|
| 2873 | """ |
|
| @@ 33-74 (lines=42) @@ | ||
| 30 | ||
| 31 | fixtures = [BaseFixture, ContentFixtures] |
|
| 32 | ||
| 33 | def test_api__get_workspace__ok_200__nominal_case(self) -> None: |
|
| 34 | """ |
|
| 35 | Check obtain workspace reachable for user. |
|
| 36 | """ |
|
| 37 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 38 | admin = dbsession.query(models.User) \ |
|
| 39 | .filter(models.User.email == '[email protected]') \ |
|
| 40 | .one() |
|
| 41 | ||
| 42 | workspace_api = WorkspaceApi( |
|
| 43 | session=dbsession, |
|
| 44 | current_user=admin, |
|
| 45 | config=self.app_config, |
|
| 46 | ) |
|
| 47 | workspace = workspace_api.get_one(1) |
|
| 48 | app_api = ApplicationApi( |
|
| 49 | app_list |
|
| 50 | ) |
|
| 51 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 52 | ||
| 53 | self.testapp.authorization = ( |
|
| 54 | 'Basic', |
|
| 55 | ( |
|
| 56 | '[email protected]', |
|
| 57 | '[email protected]' |
|
| 58 | ) |
|
| 59 | ) |
|
| 60 | res = self.testapp.get('/api/v2/workspaces/1', status=200) |
|
| 61 | workspace = res.json_body |
|
| 62 | assert workspace['workspace_id'] == 1 |
|
| 63 | assert workspace['slug'] == 'business' |
|
| 64 | assert workspace['label'] == 'Business' |
|
| 65 | assert workspace['description'] == 'All importants documents' |
|
| 66 | assert workspace['is_deleted'] is False |
|
| 67 | ||
| 68 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 69 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 70 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 71 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 72 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 73 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 74 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 75 | ||
| 76 | def test_api__update_workspace__ok_200__nominal_case(self) -> None: |
|
| 77 | """ |
|