| @@ 1186-1276 (lines=91) @@ | ||
| 1183 | assert res[0]['public_name'] == test_user.display_name |
|
| 1184 | assert res[0]['avatar_url'] is None |
|
| 1185 | ||
| 1186 | def test_api__get_user__ok_200__admin__by_name_exclude_workspace(self): |
|
| 1187 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 1188 | admin = dbsession.query(models.User) \ |
|
| 1189 | .filter(models.User.email == '[email protected]') \ |
|
| 1190 | .one() |
|
| 1191 | uapi = UserApi( |
|
| 1192 | current_user=admin, |
|
| 1193 | session=dbsession, |
|
| 1194 | config=self.app_config, |
|
| 1195 | ) |
|
| 1196 | gapi = GroupApi( |
|
| 1197 | current_user=admin, |
|
| 1198 | session=dbsession, |
|
| 1199 | config=self.app_config, |
|
| 1200 | ) |
|
| 1201 | groups = [gapi.get_one_with_name('users')] |
|
| 1202 | test_user = uapi.create_user( |
|
| 1203 | email='[email protected]', |
|
| 1204 | password='pass', |
|
| 1205 | name='bob', |
|
| 1206 | groups=groups, |
|
| 1207 | timezone='Europe/Paris', |
|
| 1208 | lang='fr', |
|
| 1209 | do_save=True, |
|
| 1210 | do_notify=False, |
|
| 1211 | ) |
|
| 1212 | test_user2 = uapi.create_user( |
|
| 1213 | email='[email protected]', |
|
| 1214 | password='pass', |
|
| 1215 | name='bob2', |
|
| 1216 | groups=groups, |
|
| 1217 | timezone='Europe/Paris', |
|
| 1218 | lang='fr', |
|
| 1219 | do_save=True, |
|
| 1220 | do_notify=False, |
|
| 1221 | ) |
|
| 1222 | workspace_api = WorkspaceApi( |
|
| 1223 | current_user=admin, |
|
| 1224 | session=dbsession, |
|
| 1225 | config=self.app_config |
|
| 1226 | ||
| 1227 | ) |
|
| 1228 | workspace = WorkspaceApi( |
|
| 1229 | current_user=admin, |
|
| 1230 | session=dbsession, |
|
| 1231 | config=self.app_config, |
|
| 1232 | ).create_workspace( |
|
| 1233 | 'test workspace', |
|
| 1234 | save_now=True |
|
| 1235 | ) |
|
| 1236 | workspace2 = WorkspaceApi( |
|
| 1237 | current_user=admin, |
|
| 1238 | session=dbsession, |
|
| 1239 | config=self.app_config, |
|
| 1240 | ).create_workspace( |
|
| 1241 | 'test workspace2', |
|
| 1242 | save_now=True |
|
| 1243 | ) |
|
| 1244 | role_api = RoleApi( |
|
| 1245 | current_user=admin, |
|
| 1246 | session=dbsession, |
|
| 1247 | config=self.app_config, |
|
| 1248 | ) |
|
| 1249 | role_api.create_one(test_user, workspace, UserRoleInWorkspace.READER, False) |
|
| 1250 | role_api.create_one(test_user2, workspace2, UserRoleInWorkspace.READER, False) |
|
| 1251 | uapi.save(test_user) |
|
| 1252 | uapi.save(test_user2) |
|
| 1253 | transaction.commit() |
|
| 1254 | user_id = int(admin.user_id) |
|
| 1255 | ||
| 1256 | self.testapp.authorization = ( |
|
| 1257 | 'Basic', |
|
| 1258 | ( |
|
| 1259 | '[email protected]', |
|
| 1260 | '[email protected]' |
|
| 1261 | ) |
|
| 1262 | ) |
|
| 1263 | params = { |
|
| 1264 | 'acp': 'bob', |
|
| 1265 | 'exclude_workspace_ids': [workspace2.workspace_id] |
|
| 1266 | } |
|
| 1267 | res = self.testapp.get( |
|
| 1268 | '/api/v2/users/me/known_members', |
|
| 1269 | status=200, |
|
| 1270 | params=params, |
|
| 1271 | ) |
|
| 1272 | res = res.json_body |
|
| 1273 | assert len(res) == 1 |
|
| 1274 | assert res[0]['user_id'] == test_user.user_id |
|
| 1275 | assert res[0]['public_name'] == test_user.display_name |
|
| 1276 | assert res[0]['avatar_url'] is None |
|
| 1277 | ||
| 1278 | def test_api__get_user__ok_200__admin__by_name_exclude_workspace_and_user(self): |
|
| 1279 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| @@ 3921-4011 (lines=91) @@ | ||
| 3918 | assert res[0]['public_name'] == test_user.display_name |
|
| 3919 | assert res[0]['avatar_url'] is None |
|
| 3920 | ||
| 3921 | def test_api__get_user__ok_200__admin__by_name_exclude_workspace(self): |
|
| 3922 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 3923 | admin = dbsession.query(models.User) \ |
|
| 3924 | .filter(models.User.email == '[email protected]') \ |
|
| 3925 | .one() |
|
| 3926 | uapi = UserApi( |
|
| 3927 | current_user=admin, |
|
| 3928 | session=dbsession, |
|
| 3929 | config=self.app_config, |
|
| 3930 | ) |
|
| 3931 | gapi = GroupApi( |
|
| 3932 | current_user=admin, |
|
| 3933 | session=dbsession, |
|
| 3934 | config=self.app_config, |
|
| 3935 | ) |
|
| 3936 | groups = [gapi.get_one_with_name('users')] |
|
| 3937 | test_user = uapi.create_user( |
|
| 3938 | email='[email protected]', |
|
| 3939 | password='pass', |
|
| 3940 | name='bob', |
|
| 3941 | groups=groups, |
|
| 3942 | timezone='Europe/Paris', |
|
| 3943 | lang='fr', |
|
| 3944 | do_save=True, |
|
| 3945 | do_notify=False, |
|
| 3946 | ) |
|
| 3947 | test_user2 = uapi.create_user( |
|
| 3948 | email='[email protected]', |
|
| 3949 | password='pass', |
|
| 3950 | name='bob2', |
|
| 3951 | groups=groups, |
|
| 3952 | timezone='Europe/Paris', |
|
| 3953 | lang='fr', |
|
| 3954 | do_save=True, |
|
| 3955 | do_notify=False, |
|
| 3956 | ) |
|
| 3957 | workspace_api = WorkspaceApi( |
|
| 3958 | current_user=admin, |
|
| 3959 | session=dbsession, |
|
| 3960 | config=self.app_config |
|
| 3961 | ||
| 3962 | ) |
|
| 3963 | workspace = WorkspaceApi( |
|
| 3964 | current_user=admin, |
|
| 3965 | session=dbsession, |
|
| 3966 | config=self.app_config, |
|
| 3967 | ).create_workspace( |
|
| 3968 | 'test workspace', |
|
| 3969 | save_now=True |
|
| 3970 | ) |
|
| 3971 | workspace2 = WorkspaceApi( |
|
| 3972 | current_user=admin, |
|
| 3973 | session=dbsession, |
|
| 3974 | config=self.app_config, |
|
| 3975 | ).create_workspace( |
|
| 3976 | 'test workspace2', |
|
| 3977 | save_now=True |
|
| 3978 | ) |
|
| 3979 | role_api = RoleApi( |
|
| 3980 | current_user=admin, |
|
| 3981 | session=dbsession, |
|
| 3982 | config=self.app_config, |
|
| 3983 | ) |
|
| 3984 | role_api.create_one(test_user, workspace, UserRoleInWorkspace.READER, False) |
|
| 3985 | role_api.create_one(test_user2, workspace2, UserRoleInWorkspace.READER, False) |
|
| 3986 | uapi.save(test_user) |
|
| 3987 | uapi.save(test_user2) |
|
| 3988 | transaction.commit() |
|
| 3989 | user_id = int(admin.user_id) |
|
| 3990 | ||
| 3991 | self.testapp.authorization = ( |
|
| 3992 | 'Basic', |
|
| 3993 | ( |
|
| 3994 | '[email protected]', |
|
| 3995 | '[email protected]' |
|
| 3996 | ) |
|
| 3997 | ) |
|
| 3998 | params = { |
|
| 3999 | 'acp': 'bob', |
|
| 4000 | 'exclude_workspace_ids': [workspace2.workspace_id] |
|
| 4001 | } |
|
| 4002 | res = self.testapp.get( |
|
| 4003 | '/api/v2/users/{user_id}/known_members'.format(user_id=user_id), |
|
| 4004 | status=200, |
|
| 4005 | params=params, |
|
| 4006 | ) |
|
| 4007 | res = res.json_body |
|
| 4008 | assert len(res) == 1 |
|
| 4009 | assert res[0]['user_id'] == test_user.user_id |
|
| 4010 | assert res[0]['public_name'] == test_user.display_name |
|
| 4011 | assert res[0]['avatar_url'] is None |
|
| 4012 | ||
| 4013 | def test_api__get_user__ok_200__admin__by_name_exclude_workspace_and_user(self): |
|
| 4014 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|