| @@ 2869-2910 (lines=42) @@ | ||
| 2866 | """ |
|
| 2867 | fixtures = [BaseFixture, ContentFixtures] |
|
| 2868 | ||
| 2869 | def test_api__get_user_workspaces__ok_200__nominal_case(self): |
|
| 2870 | """ |
|
| 2871 | Check obtain all workspaces reachables for user with user auth. |
|
| 2872 | """ |
|
| 2873 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 2874 | admin = dbsession.query(models.User) \ |
|
| 2875 | .filter(models.User.email == '[email protected]') \ |
|
| 2876 | .one() |
|
| 2877 | ||
| 2878 | workspace_api = WorkspaceApi( |
|
| 2879 | session=dbsession, |
|
| 2880 | current_user=admin, |
|
| 2881 | config=self.app_config, |
|
| 2882 | ) |
|
| 2883 | workspace = workspace_api.get_one(1) |
|
| 2884 | app_api = ApplicationApi( |
|
| 2885 | app_list |
|
| 2886 | ) |
|
| 2887 | ||
| 2888 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 2889 | self.testapp.authorization = ( |
|
| 2890 | 'Basic', |
|
| 2891 | ( |
|
| 2892 | '[email protected]', |
|
| 2893 | '[email protected]' |
|
| 2894 | ) |
|
| 2895 | ) |
|
| 2896 | res = self.testapp.get('/api/v2/users/1/workspaces', status=200) |
|
| 2897 | res = res.json_body |
|
| 2898 | workspace = res[0] |
|
| 2899 | assert workspace['workspace_id'] == 1 |
|
| 2900 | assert workspace['label'] == 'Business' |
|
| 2901 | assert workspace['slug'] == 'business' |
|
| 2902 | assert workspace['is_deleted'] is False |
|
| 2903 | ||
| 2904 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 2905 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 2906 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 2907 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 2908 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 2909 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 2910 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 2911 | ||
| 2912 | def test_api__get_user_workspaces__err_403__unallowed_user(self): |
|
| 2913 | """ |
|
| @@ 946-987 (lines=42) @@ | ||
| 943 | """ |
|
| 944 | fixtures = [BaseFixture, ContentFixtures] |
|
| 945 | ||
| 946 | def test_api__get_account_workspaces__ok_200__nominal_case(self): |
|
| 947 | """ |
|
| 948 | Check obtain all workspaces reachables for user with user auth. |
|
| 949 | """ |
|
| 950 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 951 | admin = dbsession.query(models.User) \ |
|
| 952 | .filter(models.User.email == '[email protected]') \ |
|
| 953 | .one() |
|
| 954 | ||
| 955 | workspace_api = WorkspaceApi( |
|
| 956 | session=dbsession, |
|
| 957 | current_user=admin, |
|
| 958 | config=self.app_config, |
|
| 959 | ) |
|
| 960 | workspace = workspace_api.get_one(1) |
|
| 961 | app_api = ApplicationApi( |
|
| 962 | app_list |
|
| 963 | ) |
|
| 964 | ||
| 965 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 966 | self.testapp.authorization = ( |
|
| 967 | 'Basic', |
|
| 968 | ( |
|
| 969 | '[email protected]', |
|
| 970 | '[email protected]' |
|
| 971 | ) |
|
| 972 | ) |
|
| 973 | res = self.testapp.get('/api/v2/users/1/workspaces', status=200) |
|
| 974 | res = res.json_body |
|
| 975 | workspace = res[0] |
|
| 976 | assert workspace['workspace_id'] == 1 |
|
| 977 | assert workspace['label'] == 'Business' |
|
| 978 | assert workspace['slug'] == 'business' |
|
| 979 | assert workspace['is_deleted'] is False |
|
| 980 | ||
| 981 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 982 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 983 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 984 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 985 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 986 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 987 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 988 | ||
| 989 | ||
| 990 | class TestAccountEndpoint(FunctionalTest): |
|
| @@ 35-76 (lines=42) @@ | ||
| 32 | ||
| 33 | fixtures = [BaseFixture, ContentFixtures] |
|
| 34 | ||
| 35 | def test_api__get_workspace__ok_200__nominal_case(self) -> None: |
|
| 36 | """ |
|
| 37 | Check obtain workspace reachable for user. |
|
| 38 | """ |
|
| 39 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 40 | admin = dbsession.query(models.User) \ |
|
| 41 | .filter(models.User.email == '[email protected]') \ |
|
| 42 | .one() |
|
| 43 | ||
| 44 | workspace_api = WorkspaceApi( |
|
| 45 | session=dbsession, |
|
| 46 | current_user=admin, |
|
| 47 | config=self.app_config, |
|
| 48 | ) |
|
| 49 | workspace = workspace_api.get_one(1) |
|
| 50 | app_api = ApplicationApi( |
|
| 51 | app_list |
|
| 52 | ) |
|
| 53 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 54 | ||
| 55 | self.testapp.authorization = ( |
|
| 56 | 'Basic', |
|
| 57 | ( |
|
| 58 | '[email protected]', |
|
| 59 | '[email protected]' |
|
| 60 | ) |
|
| 61 | ) |
|
| 62 | res = self.testapp.get('/api/v2/workspaces/1', status=200) |
|
| 63 | workspace = res.json_body |
|
| 64 | assert workspace['workspace_id'] == 1 |
|
| 65 | assert workspace['slug'] == 'business' |
|
| 66 | assert workspace['label'] == 'Business' |
|
| 67 | assert workspace['description'] == 'All importants documents' |
|
| 68 | assert workspace['is_deleted'] is False |
|
| 69 | ||
| 70 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 71 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 72 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 73 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 74 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 75 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 76 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 77 | ||
| 78 | def test_api__update_workspace__ok_200__nominal_case(self) -> None: |
|
| 79 | """ |
|