@@ 3433-3484 (lines=52) @@ | ||
3430 | assert 'code' in res.json.keys() |
|
3431 | assert res.json_body['code'] == error.EMAIL_ALREADY_EXIST_IN_DB |
|
3432 | ||
3433 | def test_api__create_user__err_403__other_user(self): |
|
3434 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3435 | admin = dbsession.query(models.User) \ |
|
3436 | .filter(models.User.email == '[email protected]') \ |
|
3437 | .one() |
|
3438 | uapi = UserApi( |
|
3439 | current_user=admin, |
|
3440 | session=dbsession, |
|
3441 | config=self.app_config, |
|
3442 | ) |
|
3443 | gapi = GroupApi( |
|
3444 | current_user=admin, |
|
3445 | session=dbsession, |
|
3446 | config=self.app_config, |
|
3447 | ) |
|
3448 | groups = [gapi.get_one_with_name('users')] |
|
3449 | test_user = uapi.create_user( |
|
3450 | email='[email protected]', |
|
3451 | password='pass', |
|
3452 | name='bob', |
|
3453 | groups=groups, |
|
3454 | timezone='Europe/Paris', |
|
3455 | lang='fr', |
|
3456 | do_save=True, |
|
3457 | do_notify=False, |
|
3458 | ) |
|
3459 | uapi.save(test_user) |
|
3460 | transaction.commit() |
|
3461 | self.testapp.authorization = ( |
|
3462 | 'Basic', |
|
3463 | ( |
|
3464 | '[email protected]', |
|
3465 | 'pass', |
|
3466 | ) |
|
3467 | ) |
|
3468 | params = { |
|
3469 | 'email': '[email protected]', |
|
3470 | 'password': 'mysuperpassword', |
|
3471 | 'profile': 'users', |
|
3472 | 'timezone': 'Europe/Paris', |
|
3473 | 'public_name': 'test user', |
|
3474 | 'lang': 'fr', |
|
3475 | 'email_notification': False, |
|
3476 | } |
|
3477 | res = self.testapp.post_json( |
|
3478 | '/api/v2/users', |
|
3479 | status=403, |
|
3480 | params=params, |
|
3481 | ) |
|
3482 | assert isinstance(res.json, dict) |
|
3483 | assert 'code' in res.json.keys() |
|
3484 | assert res.json_body['code'] == error.INSUFFICIENT_USER_PROFILE |
|
3485 | ||
3486 | ||
3487 | class TestUserWithNotificationEndpoint(FunctionalTest): |
|
@@ 3380-3431 (lines=52) @@ | ||
3377 | assert user.email == '[email protected]' |
|
3378 | assert user.password |
|
3379 | ||
3380 | def test_api__create_user__err_400__email_already_in_db(self): |
|
3381 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
3382 | admin = dbsession.query(models.User) \ |
|
3383 | .filter(models.User.email == '[email protected]') \ |
|
3384 | .one() |
|
3385 | uapi = UserApi( |
|
3386 | current_user=admin, |
|
3387 | session=dbsession, |
|
3388 | config=self.app_config, |
|
3389 | ) |
|
3390 | gapi = GroupApi( |
|
3391 | current_user=admin, |
|
3392 | session=dbsession, |
|
3393 | config=self.app_config, |
|
3394 | ) |
|
3395 | groups = [gapi.get_one_with_name('users')] |
|
3396 | test_user = uapi.create_user( |
|
3397 | email='[email protected]', |
|
3398 | password='pass', |
|
3399 | name='bob', |
|
3400 | groups=groups, |
|
3401 | timezone='Europe/Paris', |
|
3402 | lang='fr', |
|
3403 | do_save=True, |
|
3404 | do_notify=False, |
|
3405 | ) |
|
3406 | uapi.save(test_user) |
|
3407 | transaction.commit() |
|
3408 | self.testapp.authorization = ( |
|
3409 | 'Basic', |
|
3410 | ( |
|
3411 | '[email protected]', |
|
3412 | '[email protected]' |
|
3413 | ) |
|
3414 | ) |
|
3415 | params = { |
|
3416 | 'email': '[email protected]', |
|
3417 | 'password': 'mysuperpassword', |
|
3418 | 'profile': 'users', |
|
3419 | 'timezone': 'Europe/Paris', |
|
3420 | 'lang': 'fr', |
|
3421 | 'public_name': 'test user', |
|
3422 | 'email_notification': False, |
|
3423 | } |
|
3424 | res = self.testapp.post_json( |
|
3425 | '/api/v2/users', |
|
3426 | status=400, |
|
3427 | params=params, |
|
3428 | ) |
|
3429 | assert isinstance(res.json, dict) |
|
3430 | assert 'code' in res.json.keys() |
|
3431 | assert res.json_body['code'] == error.EMAIL_ALREADY_EXIST_IN_DB |
|
3432 | ||
3433 | def test_api__create_user__err_403__other_user(self): |
|
3434 | dbsession = get_tm_session(self.session_factory, transaction.manager) |