1
0
mirror of https://github.com/linkedin/oncall.git synced 2025-12-08 00:32:59 +02:00

add e2e test for updating user contacts, change from tuple to list

This commit is contained in:
William Leese
2018-01-10 09:39:39 +01:00
committed by Daniel Wang
parent d019ee280e
commit 30eda364ab
2 changed files with 9 additions and 4 deletions

View File

@@ -31,6 +31,10 @@ def test_api_v0_users():
re = requests.put(api_v0('users/'+user_name), json={'full_name': 'John Doe', 'time_zone': 'PDT'})
assert re.status_code == 204
# test updating user contacts
re = requests.put(api_v0('users/'+user_name), json={'full_name': 'John Doe', 'contacts': {'call': '+1 333-333-3339'}})
assert re.status_code == 204
# make sure update has gone through, test get
re = requests.get(api_v0('users/'+user_name))
assert re.status_code == 200
@@ -43,11 +47,12 @@ def test_api_v0_users():
response = re.json()
assert response[0]['full_name'] == 'John Doe'
re = requests.get(api_v0('users'), params={'name': user_name, 'fields': ['full_name', 'time_zone']})
re = requests.get(api_v0('users'), params={'name': user_name, 'fields': ['full_name', 'time_zone', 'contacts']})
assert re.status_code == 200
response = json.loads(re.text)
assert response[0]['full_name'] == 'John Doe'
assert response[0]['time_zone'] == 'PDT'
assert response[0]['contacts']['call'] == '+1 333-333-3339'
clean_up()

View File

@@ -143,11 +143,11 @@ def on_put(req, resp, user_name):
cursor = connection.cursor()
if set_clause:
query = 'UPDATE `user` SET {0} WHERE `name` = %s'.format(set_clause)
query_data = ()
query_data = []
for field in data:
if field != 'contacts':
query_data += (data[field],)
query_data += (user_name,)
query_data.append(data[field])
query_data.append(user_name)
cursor.execute(query, query_data)
if cursor.rowcount != 1: