From ac15e7fd8bcc74c2181b75e7b67782d905fed40e Mon Sep 17 00:00:00 2001 From: Ken Tsang Date: Tue, 7 Nov 2017 12:19:44 +0000 Subject: [PATCH] Renamed `inbound_sms_list` key name to `received_text_messages` --- app/v2/inbound_sms/get_inbound_sms.py | 4 ++-- app/v2/inbound_sms/inbound_sms_schemas.py | 4 ++-- tests/app/v2/inbound_sms/test_get_inbound_sms.py | 16 ++++++++-------- .../v2/inbound_sms/test_inbound_sms_schemas.py | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/v2/inbound_sms/get_inbound_sms.py b/app/v2/inbound_sms/get_inbound_sms.py index 1ebae90c5..563491a55 100644 --- a/app/v2/inbound_sms/get_inbound_sms.py +++ b/app/v2/inbound_sms/get_inbound_sms.py @@ -34,7 +34,7 @@ def get_inbound_sms_by_number(user_number): ) return jsonify( - inbound_sms_list=[i.serialize() for i in paginated_inbound_sms], + received_text_messages=[i.serialize() for i in paginated_inbound_sms], links=_build_links( paginated_inbound_sms, endpoint='get_inbound_sms_by_number', @@ -58,7 +58,7 @@ def get_all_inbound_sms(): ) return jsonify( - inbound_sms_list=[i.serialize() for i in paginated_inbound_sms], + received_text_messages=[i.serialize() for i in paginated_inbound_sms], links=_build_links(paginated_inbound_sms, endpoint='get_all_inbound_sms') ), 200 diff --git a/app/v2/inbound_sms/inbound_sms_schemas.py b/app/v2/inbound_sms/inbound_sms_schemas.py index 0990c1e2e..d21c2b27b 100644 --- a/app/v2/inbound_sms/inbound_sms_schemas.py +++ b/app/v2/inbound_sms/inbound_sms_schemas.py @@ -36,7 +36,7 @@ get_inbound_sms_response = { "description": "GET list of inbound sms response schema", "type": "object", "properties": { - "inbound_sms_list": { + "received_text_messages": { "type": "array", "items": { "type": "object", @@ -57,7 +57,7 @@ get_inbound_sms_response = { "required": ["current"] } }, - "required": ["inbound_sms_list", "links"], + "required": ["received_text_messages", "links"], "definitions": { "inbound_sms": get_inbound_sms_single_response } diff --git a/tests/app/v2/inbound_sms/test_get_inbound_sms.py b/tests/app/v2/inbound_sms/test_get_inbound_sms.py index 1f1f1c771..a45a01928 100644 --- a/tests/app/v2/inbound_sms/test_get_inbound_sms.py +++ b/tests/app/v2/inbound_sms/test_get_inbound_sms.py @@ -25,7 +25,7 @@ def test_get_all_inbound_sms_returns_200( assert response.status_code == 200 assert response.headers['Content-type'] == 'application/json' - json_response = json.loads(response.get_data(as_text=True))['inbound_sms_list'] + json_response = json.loads(response.get_data(as_text=True))['received_text_messages'] reversed_all_inbound_sms = sorted(all_inbound_sms, key=lambda sms: sms.created_at, reverse=True) @@ -63,7 +63,7 @@ def test_get_inbound_sms_generate_page_links( json_response = json.loads(response.get_data(as_text=True)) expected_inbound_sms_list = [i.serialize() for i in reversed_inbound_sms[:2]] - assert json_response['inbound_sms_list'] == expected_inbound_sms_list + assert json_response['received_text_messages'] == expected_inbound_sms_list assert url_for( inbound_sms_path, user_number=user_number, @@ -104,7 +104,7 @@ def test_get_next_inbound_sms_will_get_correct_inbound_sms_list( json_response = json.loads(response.get_data(as_text=True)) expected_inbound_sms_list = [i.serialize() for i in reversed_inbound_sms[2:]] - assert json_response['inbound_sms_list'] == expected_inbound_sms_list + assert json_response['received_text_messages'] == expected_inbound_sms_list assert url_for( inbound_sms_path, user_number=user_number, @@ -137,7 +137,7 @@ def test_get_next_inbound_sms_at_end_will_return_empty_inbound_sms_list( json_response = json.loads(response.get_data(as_text=True)) expected_inbound_sms_list = [] - assert json_response['inbound_sms_list'] == expected_inbound_sms_list + assert json_response['received_text_messages'] == expected_inbound_sms_list assert url_for( inbound_sms_path, user_number=user_number, @@ -156,7 +156,7 @@ def test_get_all_inbound_sms_for_no_inbound_sms_returns_200( assert response.status_code == 200 assert response.headers['Content-type'] == 'application/json' - json_response = json.loads(response.get_data(as_text=True))['inbound_sms_list'] + json_response = json.loads(response.get_data(as_text=True))['received_text_messages'] expected_response = [] @@ -184,7 +184,7 @@ def test_get_inbound_sms_by_number_returns_200( assert response.status_code == 200 assert response.headers['Content-type'] == 'application/json' - json_response = json.loads(response.get_data(as_text=True))['inbound_sms_list'] + json_response = json.loads(response.get_data(as_text=True))['received_text_messages'] expected_response = [sample_inbound_sms2.serialize(), sample_inbound_sms1.serialize()] @@ -202,7 +202,7 @@ def test_get_inbound_sms_for_no_inbound_sms_returns_200( assert response.status_code == 200 assert response.headers['Content-type'] == 'application/json' - json_response = json.loads(response.get_data(as_text=True))['inbound_sms_list'] + json_response = json.loads(response.get_data(as_text=True))['received_text_messages'] expected_response = [] @@ -218,7 +218,7 @@ def test_get_inbound_sms_by_nonexistent_number(client, sample_service): assert response.status_code == 200 assert response.headers['Content-type'] == 'application/json' - json_response = json.loads(response.get_data(as_text=True))['inbound_sms_list'] + json_response = json.loads(response.get_data(as_text=True))['received_text_messages'] expected_response = [] assert json_response == expected_response diff --git a/tests/app/v2/inbound_sms/test_inbound_sms_schemas.py b/tests/app/v2/inbound_sms/test_inbound_sms_schemas.py index 6365d90a5..47db068ea 100644 --- a/tests/app/v2/inbound_sms/test_inbound_sms_schemas.py +++ b/tests/app/v2/inbound_sms/test_inbound_sms_schemas.py @@ -20,7 +20,7 @@ valid_inbound_sms = { } valid_inbound_sms_list = { - "inbound_sms_list": [valid_inbound_sms], + "received_text_messages": [valid_inbound_sms], "links": { "current": valid_inbound_sms["id"] } @@ -38,7 +38,7 @@ invalid_inbound_sms = { } invalid_inbound_sms_list = { - "inbound_sms_list": [invalid_inbound_sms] + "received_text_messages": [invalid_inbound_sms] } @@ -47,7 +47,7 @@ def test_get_inbound_sms_contract(client, sample_inbound_sms): response = client.get('/v2/received-text-messages/{}'.format(sample_inbound_sms.user_number), headers=[auth_header]) response_json = json.loads(response.get_data(as_text=True)) - assert validate(response_json, get_inbound_sms_response)['inbound_sms_list'][0] \ + assert validate(response_json, get_inbound_sms_response)['received_text_messages'][0] \ == sample_inbound_sms.serialize()