mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Add separate endpoint to update a single user attr
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from flask import url_for, current_app
|
||||
from freezegun import freeze_time
|
||||
@@ -180,6 +181,29 @@ def test_put_user(notify_api, notify_db, notify_db_session, sample_service):
|
||||
assert sorted(expected_permissions) == sorted(fetched['permissions'][str(sample_service.id)])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user_attribute, user_value', [
|
||||
('name', 'New User'),
|
||||
('email_address', 'newuser@mail.com'),
|
||||
('mobile_number', '+4407700900460')
|
||||
])
|
||||
def test_put_user_attribute(client, sample_user, user_attribute, user_value):
|
||||
assert getattr(sample_user, user_attribute) != user_value
|
||||
update_dict = {
|
||||
user_attribute: user_value
|
||||
}
|
||||
auth_header = create_authorization_header()
|
||||
headers = [('Content-Type', 'application/json'), auth_header]
|
||||
|
||||
resp = client.put(
|
||||
url_for('user.update_user_attribute', user_id=sample_user.id),
|
||||
data=json.dumps(update_dict),
|
||||
headers=headers)
|
||||
|
||||
assert resp.status_code == 200
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data'][user_attribute] == user_value
|
||||
|
||||
|
||||
def test_put_user_update_password(notify_api,
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
|
||||
Reference in New Issue
Block a user