mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Merge branch 'master' into tech-failures
This commit is contained in:
@@ -98,6 +98,7 @@ class Service(db.Model, Versioned):
|
|||||||
email_from = db.Column(db.Text, index=False, unique=True, nullable=False)
|
email_from = db.Column(db.Text, index=False, unique=True, nullable=False)
|
||||||
created_by = db.relationship('User')
|
created_by = db.relationship('User')
|
||||||
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
|
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
|
||||||
|
reply_to_email_address = db.Column(db.Text, index=False, unique=False, nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class ApiKey(db.Model, Versioned):
|
class ApiKey(db.Model, Versioned):
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ def create_service():
|
|||||||
@service.route('/<uuid:service_id>', methods=['POST'])
|
@service.route('/<uuid:service_id>', methods=['POST'])
|
||||||
def update_service(service_id):
|
def update_service(service_id):
|
||||||
fetched_service = dao_fetch_service_by_id(service_id)
|
fetched_service = dao_fetch_service_by_id(service_id)
|
||||||
|
|
||||||
current_data = dict(service_schema.dump(fetched_service).data.items())
|
current_data = dict(service_schema.dump(fetched_service).data.items())
|
||||||
current_data.update(request.get_json())
|
current_data.update(request.get_json())
|
||||||
update_dict, errors = service_schema.load(current_data)
|
update_dict, errors = service_schema.load(current_data)
|
||||||
|
|||||||
28
migrations/versions/0016_reply_to_email.py
Normal file
28
migrations/versions/0016_reply_to_email.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0016_reply_to_email
|
||||||
|
Revises: 0015_fix_template_data
|
||||||
|
Create Date: 2016-05-17 09:59:49.032865
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0016_reply_to_email'
|
||||||
|
down_revision = '0015_fix_template_data'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('services', sa.Column('reply_to_email_address', sa.Text(), nullable=True))
|
||||||
|
op.add_column('services_history', sa.Column('reply_to_email_address', sa.Text(), nullable=True))
|
||||||
|
### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('services_history', 'reply_to_email_address')
|
||||||
|
op.drop_column('services', 'reply_to_email_address')
|
||||||
|
### end Alembic commands ###
|
||||||
@@ -898,3 +898,31 @@ def test_get_service_and_api_key_history(notify_api, notify_db, notify_db_sessio
|
|||||||
json_resp = json.loads(response.get_data(as_text=True))
|
json_resp = json.loads(response.get_data(as_text=True))
|
||||||
assert json_resp['data']['service_history'][0]['id'] == str(sample_service.id)
|
assert json_resp['data']['service_history'][0]['id'] == str(sample_service.id)
|
||||||
assert json_resp['data']['api_key_history'][0]['id'] == str(api_key.id)
|
assert json_resp['data']['api_key_history'][0]['id'] == str(api_key.id)
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_reply_to_email_for_service(notify_api, sample_service):
|
||||||
|
with notify_api.test_request_context():
|
||||||
|
with notify_api.test_client() as client:
|
||||||
|
auth_header = create_authorization_header()
|
||||||
|
resp = client.get(
|
||||||
|
'/service/{}'.format(sample_service.id),
|
||||||
|
headers=[auth_header]
|
||||||
|
)
|
||||||
|
json_resp = json.loads(resp.get_data(as_text=True))
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert json_resp['data']['name'] == sample_service.name
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'reply_to_email_address': 'reply_test@service.gov.uk',
|
||||||
|
}
|
||||||
|
|
||||||
|
auth_header = create_authorization_header()
|
||||||
|
|
||||||
|
resp = client.post(
|
||||||
|
'/service/{}'.format(sample_service.id),
|
||||||
|
data=json.dumps(data),
|
||||||
|
headers=[('Content-Type', 'application/json'), auth_header]
|
||||||
|
)
|
||||||
|
result = json.loads(resp.get_data(as_text=True))
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert result['data']['reply_to_email_address'] == 'reply_test@service.gov.uk'
|
||||||
|
|||||||
Reference in New Issue
Block a user