mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Added more tests
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
from app import db
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.models import Organisation, InvitedOrganisationUser, User
|
||||
from app.models import (
|
||||
Organisation,
|
||||
InvitedOrganisationUser,
|
||||
User
|
||||
)
|
||||
|
||||
|
||||
def dao_get_organisations():
|
||||
@@ -55,10 +59,10 @@ def dao_get_users_for_organisation(organisation_id):
|
||||
).order_by(User.created_at).all()
|
||||
|
||||
|
||||
@transactional
|
||||
def dao_add_user_to_organisation(organisation_id, user_id):
|
||||
organisation = dao_get_organisation_by_id(organisation_id)
|
||||
user = User.query.get(user_id)
|
||||
user = User.query.filter_by(id=user_id).filter_by(state='active').one()
|
||||
organisation.users.append(user)
|
||||
db.session.add(organisation)
|
||||
db.session.commit()
|
||||
return user
|
||||
|
||||
@@ -22,11 +22,9 @@ def accept_organisation_invitation(token):
|
||||
current_app.config['DANGEROUS_SALT'],
|
||||
max_age_seconds)
|
||||
except SignatureExpired:
|
||||
errors = {'invitation':
|
||||
['Your invitation to GOV.UK Notify has expired. '
|
||||
'Please ask the person that invited you to send you another one']}
|
||||
errors = {'invitation': ['Your invitation to GOV.UK Notify has expired. '
|
||||
'Please ask the person that invited you to send you another one']}
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
invited_user = dao_get_invited_organisation_user(invited_user_id)
|
||||
|
||||
return jsonify(data=invited_user.serialize()), 200
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ def get_organisation_services(organisation_id):
|
||||
|
||||
@organisation_blueprint.route('/<uuid:organisation_id>/users/<uuid:user_id>', methods=['POST'])
|
||||
def add_user_to_organisation(organisation_id, user_id):
|
||||
current_app.logger.info("ADDING new user")
|
||||
new_org_user = dao_add_user_to_organisation(organisation_id, user_id)
|
||||
return jsonify(data=user_schema.dump(new_org_user).data), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user