| @@ 3618-3682 (lines=65) @@ | ||
| 3615 | assert res[1]['public_name'] == test_user2.display_name |
|
| 3616 | assert res[1]['avatar_url'] is None |
|
| 3617 | ||
| 3618 | def test_api__get_user__ok_200__admin__by_email(self): |
|
| 3619 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 3620 | admin = dbsession.query(models.User) \ |
|
| 3621 | .filter(models.User.email == '[email protected]') \ |
|
| 3622 | .one() |
|
| 3623 | uapi = UserApi( |
|
| 3624 | current_user=admin, |
|
| 3625 | session=dbsession, |
|
| 3626 | config=self.app_config, |
|
| 3627 | ) |
|
| 3628 | gapi = GroupApi( |
|
| 3629 | current_user=admin, |
|
| 3630 | session=dbsession, |
|
| 3631 | config=self.app_config, |
|
| 3632 | ) |
|
| 3633 | groups = [gapi.get_one_with_name('users')] |
|
| 3634 | test_user = uapi.create_user( |
|
| 3635 | email='[email protected]', |
|
| 3636 | password='pass', |
|
| 3637 | name='bob', |
|
| 3638 | groups=groups, |
|
| 3639 | timezone='Europe/Paris', |
|
| 3640 | lang='fr', |
|
| 3641 | do_save=True, |
|
| 3642 | do_notify=False, |
|
| 3643 | ) |
|
| 3644 | test_user2 = uapi.create_user( |
|
| 3645 | email='[email protected]', |
|
| 3646 | password='pass', |
|
| 3647 | name='bob2', |
|
| 3648 | groups=groups, |
|
| 3649 | timezone='Europe/Paris', |
|
| 3650 | lang='fr', |
|
| 3651 | do_save=True, |
|
| 3652 | do_notify=False, |
|
| 3653 | ) |
|
| 3654 | uapi.save(test_user) |
|
| 3655 | uapi.save(test_user2) |
|
| 3656 | transaction.commit() |
|
| 3657 | user_id = int(admin.user_id) |
|
| 3658 | ||
| 3659 | self.testapp.authorization = ( |
|
| 3660 | 'Basic', |
|
| 3661 | ( |
|
| 3662 | '[email protected]', |
|
| 3663 | '[email protected]' |
|
| 3664 | ) |
|
| 3665 | ) |
|
| 3666 | params = { |
|
| 3667 | 'acp': 'test', |
|
| 3668 | } |
|
| 3669 | res = self.testapp.get( |
|
| 3670 | '/api/v2/users/{user_id}/known_members'.format(user_id=user_id), |
|
| 3671 | status=200, |
|
| 3672 | params=params, |
|
| 3673 | ) |
|
| 3674 | res = res.json_body |
|
| 3675 | assert len(res) == 2 |
|
| 3676 | assert res[0]['user_id'] == test_user.user_id |
|
| 3677 | assert res[0]['public_name'] == test_user.display_name |
|
| 3678 | assert res[0]['avatar_url'] is None |
|
| 3679 | ||
| 3680 | assert res[1]['user_id'] == test_user2.user_id |
|
| 3681 | assert res[1]['public_name'] == test_user2.display_name |
|
| 3682 | assert res[1]['avatar_url'] is None |
|
| 3683 | ||
| 3684 | def test_api__get_user__err_403__admin__too_small_acp(self): |
|
| 3685 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| @@ 3552-3616 (lines=65) @@ | ||
| 3549 | """ |
|
| 3550 | fixtures = [BaseFixture] |
|
| 3551 | ||
| 3552 | def test_api__get_user__ok_200__admin__by_name(self): |
|
| 3553 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
| 3554 | admin = dbsession.query(models.User) \ |
|
| 3555 | .filter(models.User.email == '[email protected]') \ |
|
| 3556 | .one() |
|
| 3557 | uapi = UserApi( |
|
| 3558 | current_user=admin, |
|
| 3559 | session=dbsession, |
|
| 3560 | config=self.app_config, |
|
| 3561 | ) |
|
| 3562 | gapi = GroupApi( |
|
| 3563 | current_user=admin, |
|
| 3564 | session=dbsession, |
|
| 3565 | config=self.app_config, |
|
| 3566 | ) |
|
| 3567 | groups = [gapi.get_one_with_name('users')] |
|
| 3568 | test_user = uapi.create_user( |
|
| 3569 | email='[email protected]', |
|
| 3570 | password='pass', |
|
| 3571 | name='bob', |
|
| 3572 | groups=groups, |
|
| 3573 | timezone='Europe/Paris', |
|
| 3574 | lang='fr', |
|
| 3575 | do_save=True, |
|
| 3576 | do_notify=False, |
|
| 3577 | ) |
|
| 3578 | test_user2 = uapi.create_user( |
|
| 3579 | email='[email protected]', |
|
| 3580 | password='pass', |
|
| 3581 | name='bob2', |
|
| 3582 | groups=groups, |
|
| 3583 | timezone='Europe/Paris', |
|
| 3584 | lang='fr', |
|
| 3585 | do_save=True, |
|
| 3586 | do_notify=False, |
|
| 3587 | ) |
|
| 3588 | uapi.save(test_user) |
|
| 3589 | uapi.save(test_user2) |
|
| 3590 | transaction.commit() |
|
| 3591 | user_id = int(admin.user_id) |
|
| 3592 | ||
| 3593 | self.testapp.authorization = ( |
|
| 3594 | 'Basic', |
|
| 3595 | ( |
|
| 3596 | '[email protected]', |
|
| 3597 | '[email protected]' |
|
| 3598 | ) |
|
| 3599 | ) |
|
| 3600 | params = { |
|
| 3601 | 'acp': 'bob', |
|
| 3602 | } |
|
| 3603 | res = self.testapp.get( |
|
| 3604 | '/api/v2/users/{user_id}/known_members'.format(user_id=user_id), |
|
| 3605 | status=200, |
|
| 3606 | params=params, |
|
| 3607 | ) |
|
| 3608 | res = res.json_body |
|
| 3609 | assert len(res) == 2 |
|
| 3610 | assert res[0]['user_id'] == test_user.user_id |
|
| 3611 | assert res[0]['public_name'] == test_user.display_name |
|
| 3612 | assert res[0]['avatar_url'] is None |
|
| 3613 | ||
| 3614 | assert res[1]['user_id'] == test_user2.user_id |
|
| 3615 | assert res[1]['public_name'] == test_user2.display_name |
|
| 3616 | assert res[1]['avatar_url'] is None |
|
| 3617 | ||
| 3618 | def test_api__get_user__ok_200__admin__by_email(self): |
|
| 3619 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|