mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Don't send notification if other service attrs changed
This commit is contained in:
@@ -119,7 +119,7 @@ def create_service():
|
|||||||
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)
|
||||||
# Capture the status change here as Marshmallow changes this later
|
# Capture the status change here as Marshmallow changes this later
|
||||||
service_going_live = fetched_service.restricted and not request.get_json().get('restricted')
|
service_going_live = fetched_service.restricted and not request.get_json().get('restricted', True)
|
||||||
|
|
||||||
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())
|
||||||
|
|||||||
@@ -1702,3 +1702,22 @@ def test_update_service_does_not_call_send_notification_for_live_service(sample_
|
|||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert not send_notification_mock.called
|
assert not send_notification_mock.called
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_service_does_not_call_send_notification_when_restricted_not_changed(sample_service, client, mocker):
|
||||||
|
send_notification_mock = mocker.patch('app.service.rest.send_notification_to_service_users')
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"name": 'Name of service'
|
||||||
|
}
|
||||||
|
|
||||||
|
auth_header = create_authorization_header()
|
||||||
|
resp = client.post(
|
||||||
|
'service/{}'.format(sample_service.id),
|
||||||
|
data=json.dumps(data),
|
||||||
|
headers=[auth_header],
|
||||||
|
content_type='application/json'
|
||||||
|
)
|
||||||
|
|
||||||
|
assert resp.status_code == 200
|
||||||
|
assert not send_notification_mock.called
|
||||||
|
|||||||
Reference in New Issue
Block a user