| @@ 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): |
|
| @@ 3027-3068 (lines=42) @@ | ||
| 3024 | """ |
|
| 3025 | fixtures = [BaseFixture, ContentFixtures] |
|
| 3026 | ||
| 3027 | def test_api__get_user_workspaces__ok_200__nominal_case(self): |
|
| 3028 | """ |
|
| 3029 | Check obtain all workspaces reachables for user with user auth. |
|
| 3030 | """ |
|
| 3031 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 3032 | admin = dbsession.query(models.User) \ |
|
| 3033 | .filter(models.User.email == '[email protected]') \ |
|
| 3034 | .one() |
|
| 3035 | ||
| 3036 | workspace_api = WorkspaceApi( |
|
| 3037 | session=dbsession, |
|
| 3038 | current_user=admin, |
|
| 3039 | config=self.app_config, |
|
| 3040 | ) |
|
| 3041 | workspace = workspace_api.get_one(1) |
|
| 3042 | app_api = ApplicationApi( |
|
| 3043 | app_list |
|
| 3044 | ) |
|
| 3045 | ||
| 3046 | default_sidebar_entry = app_api.get_default_workspace_menu_entry(workspace=workspace) # nope8 |
|
| 3047 | self.testapp.authorization = ( |
|
| 3048 | 'Basic', |
|
| 3049 | ( |
|
| 3050 | '[email protected]', |
|
| 3051 | '[email protected]' |
|
| 3052 | ) |
|
| 3053 | ) |
|
| 3054 | res = self.testapp.get('/api/v2/users/1/workspaces', status=200) |
|
| 3055 | res = res.json_body |
|
| 3056 | workspace = res[0] |
|
| 3057 | assert workspace['workspace_id'] == 1 |
|
| 3058 | assert workspace['label'] == 'Business' |
|
| 3059 | assert workspace['slug'] == 'business' |
|
| 3060 | assert workspace['is_deleted'] is False |
|
| 3061 | ||
| 3062 | assert len(workspace['sidebar_entries']) == len(default_sidebar_entry) |
|
| 3063 | for counter, sidebar_entry in enumerate(default_sidebar_entry): |
|
| 3064 | workspace['sidebar_entries'][counter]['slug'] = sidebar_entry.slug |
|
| 3065 | workspace['sidebar_entries'][counter]['label'] = sidebar_entry.label |
|
| 3066 | workspace['sidebar_entries'][counter]['route'] = sidebar_entry.route |
|
| 3067 | workspace['sidebar_entries'][counter]['hexcolor'] = sidebar_entry.hexcolor # nopep8 |
|
| 3068 | workspace['sidebar_entries'][counter]['fa_icon'] = sidebar_entry.fa_icon # nopep8 |
|
| 3069 | ||
| 3070 | def test_api__get_user_workspaces__err_403__unallowed_user(self): |
|
| 3071 | """ |
|