예제 #1
0
 def get(invitation_id):
     """Get the invitation specified by the provided id."""
     invitation = InvitationService.find_invitation_by_id(invitation_id)
     if invitation is None:
         response, status = {'message': 'The requested invitation could not be found.'}, \
                            http_status.HTTP_404_NOT_FOUND
     else:
         response, status = invitation.as_dict(), http_status.HTTP_200_OK
     return response, status
예제 #2
0
def test_delete_invitation(session, auth_mock, keycloak_mock):  # pylint:disable=unused-argument
    """Delete the specified invitation."""
    with patch.object(InvitationService, 'send_invitation', return_value=None):
        user = factory_user_model(TestUserInfo.user_test)
        org = OrgService.create_org(TestOrgInfo.org1, user_id=user.id)
        org_dictionary = org.as_dict()
        invitation_info = factory_invitation(org_dictionary['id'])
        new_invitation = InvitationService.create_invitation(invitation_info, User(user), {}, '').as_dict()
        InvitationService.delete_invitation(new_invitation['id'])
        invitation = InvitationService.find_invitation_by_id(new_invitation['id'])
        assert invitation is None
예제 #3
0
def test_find_invitation_by_id(session, auth_mock, keycloak_mock):  # pylint:disable=unused-argument
    """Find an existing invitation with the provided id."""
    with patch.object(InvitationService, 'send_invitation', return_value=None):
        user = factory_user_model(TestUserInfo.user_test)
        org = OrgService.create_org(TestOrgInfo.org1, user_id=user.id)
        org_dictionary = org.as_dict()
        invitation_info = factory_invitation(org_dictionary['id'])
        new_invitation = InvitationService.create_invitation(invitation_info, User(user), {}, '').as_dict()
        invitation = InvitationService.find_invitation_by_id(new_invitation['id']).as_dict()
        assert invitation
        assert invitation['recipient_email'] == invitation_info['recipientEmail']
예제 #4
0
 def patch(invitation_id):
     """Update the invitation specified by the provided id as retried."""
     origin = request.environ.get('HTTP_ORIGIN', 'localhost')
     try:
         invitation = InvitationService.find_invitation_by_id(invitation_id)
         if invitation is None:
             response, status = {'message': 'The requested invitation could not be found.'}, \
                                http_status.HTTP_404_NOT_FOUND
         else:
             user = UserService.find_by_jwt_token()
             response, status = invitation.update_invitation(user, origin).as_dict(), http_status.HTTP_200_OK
     except BusinessException as exception:
         response, status = {'code': exception.code, 'message': exception.message}, exception.status_code
     return response, status
예제 #5
0
def test_find_invitation_by_id_exception(session, auth_mock):  # pylint:disable=unused-argument
    """Find an existing invitation with the provided id with exception."""
    invitation = InvitationService.find_invitation_by_id(None)
    assert invitation is None