@@ 997-1046 (lines=50) @@ | ||
994 | """ |
|
995 | fixtures = [BaseFixture] |
|
996 | ||
997 | def test_api__get_user__ok_200__nominal(self): |
|
998 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
999 | admin = dbsession.query(models.User) \ |
|
1000 | .filter(models.User.email == '[email protected]') \ |
|
1001 | .one() |
|
1002 | uapi = UserApi( |
|
1003 | current_user=admin, |
|
1004 | session=dbsession, |
|
1005 | config=self.app_config, |
|
1006 | ) |
|
1007 | gapi = GroupApi( |
|
1008 | current_user=admin, |
|
1009 | session=dbsession, |
|
1010 | config=self.app_config, |
|
1011 | ) |
|
1012 | groups = [gapi.get_one_with_name('users')] |
|
1013 | test_user = uapi.create_user( |
|
1014 | email='[email protected]', |
|
1015 | password='pass', |
|
1016 | name='bob', |
|
1017 | groups=groups, |
|
1018 | timezone='Europe/Paris', |
|
1019 | lang='fr', |
|
1020 | do_save=True, |
|
1021 | do_notify=False, |
|
1022 | ) |
|
1023 | uapi.save(test_user) |
|
1024 | transaction.commit() |
|
1025 | user_id = int(test_user.user_id) |
|
1026 | ||
1027 | self.testapp.authorization = ( |
|
1028 | 'Basic', |
|
1029 | ( |
|
1030 | '[email protected]', |
|
1031 | 'pass' |
|
1032 | ) |
|
1033 | ) |
|
1034 | res = self.testapp.get( |
|
1035 | '/api/v2/users/me', |
|
1036 | status=200 |
|
1037 | ) |
|
1038 | res = res.json_body |
|
1039 | assert res['user_id'] == user_id |
|
1040 | assert res['created'] |
|
1041 | assert res['is_active'] is True |
|
1042 | assert res['profile'] == 'users' |
|
1043 | assert res['email'] == '[email protected]' |
|
1044 | assert res['public_name'] == 'bob' |
|
1045 | assert res['timezone'] == 'Europe/Paris' |
|
1046 | assert res['is_deleted'] is False |
|
1047 | ||
1048 | ||
1049 | class TestAccountKnownMembersEndpoint(FunctionalTest): |
@@ 3136-3186 (lines=51) @@ | ||
3133 | """ |
|
3134 | fixtures = [BaseFixture] |
|
3135 | ||
3136 | def test_api__get_user__ok_200__admin(self): |
|
3137 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3138 | admin = dbsession.query(models.User) \ |
|
3139 | .filter(models.User.email == '[email protected]') \ |
|
3140 | .one() |
|
3141 | uapi = UserApi( |
|
3142 | current_user=admin, |
|
3143 | session=dbsession, |
|
3144 | config=self.app_config, |
|
3145 | ) |
|
3146 | gapi = GroupApi( |
|
3147 | current_user=admin, |
|
3148 | session=dbsession, |
|
3149 | config=self.app_config, |
|
3150 | ) |
|
3151 | groups = [gapi.get_one_with_name('users')] |
|
3152 | test_user = uapi.create_user( |
|
3153 | email='[email protected]', |
|
3154 | password='pass', |
|
3155 | name='bob', |
|
3156 | groups=groups, |
|
3157 | timezone='Europe/Paris', |
|
3158 | lang='fr', |
|
3159 | do_save=True, |
|
3160 | do_notify=False, |
|
3161 | ) |
|
3162 | uapi.save(test_user) |
|
3163 | transaction.commit() |
|
3164 | user_id = int(test_user.user_id) |
|
3165 | ||
3166 | self.testapp.authorization = ( |
|
3167 | 'Basic', |
|
3168 | ( |
|
3169 | '[email protected]', |
|
3170 | '[email protected]' |
|
3171 | ) |
|
3172 | ) |
|
3173 | res = self.testapp.get( |
|
3174 | '/api/v2/users/{}'.format(user_id), |
|
3175 | status=200 |
|
3176 | ) |
|
3177 | res = res.json_body |
|
3178 | assert res['user_id'] == user_id |
|
3179 | assert res['created'] |
|
3180 | assert res['is_active'] is True |
|
3181 | assert res['profile'] == 'users' |
|
3182 | assert res['email'] == '[email protected]' |
|
3183 | assert res['public_name'] == 'bob' |
|
3184 | assert res['timezone'] == 'Europe/Paris' |
|
3185 | assert res['is_deleted'] is False |
|
3186 | assert res['lang'] == 'fr' |
|
3187 | ||
3188 | def test_api__get_user__ok_200__user_itself(self): |
|
3189 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
@@ 3188-3237 (lines=50) @@ | ||
3185 | assert res['is_deleted'] is False |
|
3186 | assert res['lang'] == 'fr' |
|
3187 | ||
3188 | def test_api__get_user__ok_200__user_itself(self): |
|
3189 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3190 | admin = dbsession.query(models.User) \ |
|
3191 | .filter(models.User.email == '[email protected]') \ |
|
3192 | .one() |
|
3193 | uapi = UserApi( |
|
3194 | current_user=admin, |
|
3195 | session=dbsession, |
|
3196 | config=self.app_config, |
|
3197 | ) |
|
3198 | gapi = GroupApi( |
|
3199 | current_user=admin, |
|
3200 | session=dbsession, |
|
3201 | config=self.app_config, |
|
3202 | ) |
|
3203 | groups = [gapi.get_one_with_name('users')] |
|
3204 | test_user = uapi.create_user( |
|
3205 | email='[email protected]', |
|
3206 | password='pass', |
|
3207 | name='bob', |
|
3208 | groups=groups, |
|
3209 | timezone='Europe/Paris', |
|
3210 | lang='fr', |
|
3211 | do_save=True, |
|
3212 | do_notify=False, |
|
3213 | ) |
|
3214 | uapi.save(test_user) |
|
3215 | transaction.commit() |
|
3216 | user_id = int(test_user.user_id) |
|
3217 | ||
3218 | self.testapp.authorization = ( |
|
3219 | 'Basic', |
|
3220 | ( |
|
3221 | '[email protected]', |
|
3222 | 'pass' |
|
3223 | ) |
|
3224 | ) |
|
3225 | res = self.testapp.get( |
|
3226 | '/api/v2/users/{}'.format(user_id), |
|
3227 | status=200 |
|
3228 | ) |
|
3229 | res = res.json_body |
|
3230 | assert res['user_id'] == user_id |
|
3231 | assert res['created'] |
|
3232 | assert res['is_active'] is True |
|
3233 | assert res['profile'] == 'users' |
|
3234 | assert res['email'] == '[email protected]' |
|
3235 | assert res['public_name'] == 'bob' |
|
3236 | assert res['timezone'] == 'Europe/Paris' |
|
3237 | assert res['is_deleted'] is False |
|
3238 | ||
3239 | def test_api__get_user__err_403__other_normal_user(self): |
|
3240 | dbsession = get_tm_session(self.session_factory, transaction.manager) |