From f8c39b30d66bf275994d8c137219de2c9b965226 Mon Sep 17 00:00:00 2001 From: Pawel Olejniczak Date: Mon, 7 Jun 2021 14:49:02 +0200 Subject: [PATCH] [CP-142] Update tests with 204 response code Uptdate python test scripts with 204 (NoContent) code for responsens with empty body. --- test/pytest/service-desktop/test_calendar.py | 6 +++--- .../service-desktop/test_calendar_events.py | 6 +++--- test/pytest/service-desktop/test_calllog.py | 2 +- test/pytest/service-desktop/test_contacts.py | 4 ++-- test/pytest/service-desktop/test_messages.py | 2 +- test/pytest/service-desktop/test_security.py | 10 +++++----- test/pytest/service-desktop/test_templates.py | 6 +++--- test/pytest/service-desktop/test_threads.py | 2 +- test/pytest/test_auto_lock.py | 2 +- test/pytest/test_change_sim.py | 4 ++-- test/pytest/test_send_message.py | 18 +++++++++--------- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/test/pytest/service-desktop/test_calendar.py b/test/pytest/service-desktop/test_calendar.py index 7182cec0b7dfac8bb68c63fda0d054d183120d36..758d424788f68af7fd05c77fb25aa5be84bff0b2 100644 --- a/test/pytest/service-desktop/test_calendar.py +++ b/test/pytest/service-desktop/test_calendar.py @@ -67,7 +67,7 @@ def test_calendar(harness): # remove event del_body = {"UID": ret["body"]["calendar_events"][0]["UID"]} ret = harness.endpoint_request("events", "del", del_body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # check events after remove body = {"offset": 0, "limit": 1} @@ -102,7 +102,7 @@ def test_calendar(harness): } ret = harness.endpoint_request("events", "post", update_body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # get updated event body = {"offset": 0, "limit": 1} @@ -131,7 +131,7 @@ def test_calendar(harness): del_body = {"UID": ret["body"]["calendar_events"][0]["UID"]} ret = harness.endpoint_request("events", "del", del_body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # check events after remove body = {"offset": 0, "limit": 1} diff --git a/test/pytest/service-desktop/test_calendar_events.py b/test/pytest/service-desktop/test_calendar_events.py index c2fad0ce5e723907b1c009991e933dad8c2a554b..bd8426f9ec782cbc96883b345b4d9a92f9d034d6 100755 --- a/test/pytest/service-desktop/test_calendar_events.py +++ b/test/pytest/service-desktop/test_calendar_events.py @@ -36,14 +36,14 @@ def test_calendar(harness): UIDS = [] ret = harness.endpoint_request("events", "put", add_body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] UIDS.insert(0,ret["body"]["UID"]) event_count = 15 for new_event_counter in range(2,event_count+1): new_event = copy.deepcopy(add_body) new_event["calendar_events"][0]["SUMMARY"] = "Test" + str(new_event_counter) ret = harness.endpoint_request("events", "put", new_event) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] UIDS.insert(new_event_counter-1,ret["body"]["UID"]) # get events limit < pageSize - pagination not used @@ -84,6 +84,6 @@ def test_calendar(harness): for ev in range(0,event_count): del_body = {"UID": UIDS[ev]} ret = harness.endpoint_request("events", "del", del_body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] diff --git a/test/pytest/service-desktop/test_calllog.py b/test/pytest/service-desktop/test_calllog.py index 823b3411d9f6c1d345c018d09e956d172de5b79d..69cb1789eac1e1c21cc6ef2942bf9f2370dada33 100644 --- a/test/pytest/service-desktop/test_calllog.py +++ b/test/pytest/service-desktop/test_calllog.py @@ -41,7 +41,7 @@ def test_calllog(harness): # remove exact call log body = {"id": calllog[0]["id"]} ret = harness.endpoint_request("calllog", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # getting the count again body = {"count": True} diff --git a/test/pytest/service-desktop/test_contacts.py b/test/pytest/service-desktop/test_contacts.py index 240bc83d097e600a9a1679184ace39c0587cc5ea..087973982708f4891319d084dc5bd809766926b7 100644 --- a/test/pytest/service-desktop/test_contacts.py +++ b/test/pytest/service-desktop/test_contacts.py @@ -93,7 +93,7 @@ def test_contacts(harness): "priName": "Test2", "id": contact_id_to_update} ret = harness.endpoint_request("contacts", "post", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # gathering updated contact body = {"id": contact_id_to_update} @@ -110,7 +110,7 @@ def test_contacts(harness): # removing added contact body = {"id": contact_id_to_update} ret = harness.endpoint_request("contacts", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # verifying count body = {"count": True} diff --git a/test/pytest/service-desktop/test_messages.py b/test/pytest/service-desktop/test_messages.py index 8053ca6d4b6f608bdfd4af94d15361e25938caa4..d6ab48680d11a8ffb3bf78b5710cf6b6405e2a18 100644 --- a/test/pytest/service-desktop/test_messages.py +++ b/test/pytest/service-desktop/test_messages.py @@ -184,7 +184,7 @@ def test_remove_message(harness): sms_to_remove = messages[0] body = {"category": "message", "messageID": sms_to_remove["messageID"]} ret = harness.endpoint_request("messages", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # get messages count again body = {"category": "message", "count": True} diff --git a/test/pytest/service-desktop/test_security.py b/test/pytest/service-desktop/test_security.py index a2dbe48c58a2a4eeb1a4d9698634abd21099b024..c9afcba3500c9fa2eae847ce48bae3a5f5fcec72 100644 --- a/test/pytest/service-desktop/test_security.py +++ b/test/pytest/service-desktop/test_security.py @@ -65,17 +65,17 @@ def test_security_phone_locked_without_code(harness): body = {"phoneLockCodeEnabled": False} ret = harness.endpoint_request("developerMode", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] time.sleep(.1) body = {} ret = harness.endpoint_request("usbSecurity", "get", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] body = {"phoneLockCodeEnabled": True} ret = harness.endpoint_request("developerMode", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] harness.lock_phone() time.sleep(.1) @@ -95,7 +95,7 @@ def test_security_unlock_phone(harness): """ body = {"phoneLockCode": [1, 1, 1, 1]} ret = harness.endpoint_request("usbSecurity", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] time.sleep(.1) @@ -138,7 +138,7 @@ def test_security_unlock_phone(harness): """ body = {"phoneLockCode": [3, 3, 3, 3]} ret = harness.endpoint_request("usbSecurity", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] time.sleep(.1) diff --git a/test/pytest/service-desktop/test_templates.py b/test/pytest/service-desktop/test_templates.py index e555ec4b2a4754fbe8b72a957258cfbad0a75ca4..8c3b6501f1385e365059cc95f12e0a844f61cd60 100644 --- a/test/pytest/service-desktop/test_templates.py +++ b/test/pytest/service-desktop/test_templates.py @@ -19,7 +19,7 @@ class TemplatesTester: def __add_template(self): body = {"category": "template", "templateBody": self.template_body} ret = self.harness.endpoint_request("messages", "post", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] return ret def __get_templates(self, limit, offset): @@ -29,7 +29,7 @@ class TemplatesTester: def __remove_template(self, template_id): body = {"category": "template", "templateID": template_id} ret = self.harness.endpoint_request("messages", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] def __get_all_templates(self): body = {"category": "template", "count": True} @@ -104,7 +104,7 @@ class TemplatesTester: new_template_body = "NEW TEMPLATE BODY TEST" body = {"category": "template", "templateID": template["templateID"], "templateBody": new_template_body} ret = self.harness.endpoint_request("messages", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # and then remove it to clean env self.__remove_template(template["templateID"]) diff --git a/test/pytest/service-desktop/test_threads.py b/test/pytest/service-desktop/test_threads.py index 1bdf0471ff79bb6d4498d5625af978a8a09b25d2..7adadeb12a7f3b1709c1274f16f5aa78d7107101 100644 --- a/test/pytest/service-desktop/test_threads.py +++ b/test/pytest/service-desktop/test_threads.py @@ -40,4 +40,4 @@ def test_threads(harness): # set thread as read body = {"category": "thread", "threadID": 1, "isUnread": False} ret = harness.endpoint_request("messages", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] diff --git a/test/pytest/test_auto_lock.py b/test/pytest/test_auto_lock.py index e9a4287ad989f502d31edee9a65358675ac6497b..05d4f08760e17d89f743d6f3696e611e337bccbb 100644 --- a/test/pytest/test_auto_lock.py +++ b/test/pytest/test_auto_lock.py @@ -12,7 +12,7 @@ import random def change_auto_lock_timer(harness, value: str): body = {"changeAutoLockTimeout": value} ret = harness.endpoint_request("developerMode", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] @pytest.fixture(scope='function') def phone_ends_with_default_auto_lock(harness): diff --git a/test/pytest/test_change_sim.py b/test/pytest/test_change_sim.py index c486de6b0adb610a96fdebfc0dada703aa622078..3d053349fecc25254f121d7a92c5488dc0e8d7a5 100644 --- a/test/pytest/test_change_sim.py +++ b/test/pytest/test_change_sim.py @@ -19,7 +19,7 @@ def test_change_sim(harness, phone_number, sms_text): # change sim to SIM1 body = {"changeSim": simCard["SIM1"]} ret = harness.endpoint_request("developerMode", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # time to change sim card in pure phone, value is experimentally chosen, no idea how to do it right time.sleep(2) @@ -37,7 +37,7 @@ def test_change_sim(harness, phone_number, sms_text): # change sim to SIM2 body = {"changeSim": simCard["SIM2"]} ret = harness.endpoint_request("developerMode", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] # time to change sim card in pure phone, value is experimentally chosen, no idea how to do it right time.sleep(2) diff --git a/test/pytest/test_send_message.py b/test/pytest/test_send_message.py index 5f3845cd8ba3275a6356527e9764675aaae83c62..0e798d0dae5ccbbb18892e750f7c6ec62fab58bf 100644 --- a/test/pytest/test_send_message.py +++ b/test/pytest/test_send_message.py @@ -44,14 +44,14 @@ def erase_all_templates(harness): for template in ret["body"]["entries"]: body = {"category": "template", "templateID": template["templateID"]} del_res = harness.endpoint_request("messages", "del", body) - assert del_res["status"] == status["OK"] + assert del_res["status"] == status["NoContent"] def add_new_template(harness, template_text: str): # adding new template body = {"category": "template", "templateBody": template_text} ret = harness.endpoint_request("messages", "post", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] def get_all_contacts(harness): @@ -97,7 +97,7 @@ def erase_contacts_by_name(harness, name): # removing added contact body = {"id": identifier} ret = harness.endpoint_request("contacts", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] def erase_contacts_by_phone_number(harness, phone_number): @@ -117,7 +117,7 @@ def erase_contacts_by_phone_number(harness, phone_number): # removing added contact body = {"id": identifier} ret = harness.endpoint_request("contacts", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] def get_message_by_text(harness, message: str, phone_number: str): @@ -168,7 +168,7 @@ def remove_added_messages(harness, diff_messages): for message in diff_messages: body = {"category": "message", "messageID": message["messageID"]} del_res = harness.endpoint_request("messages", "del", body) - assert del_res["status"] == status["OK"] + assert del_res["status"] == status["NoContent"] @pytest.mark.rt1051 @@ -399,7 +399,7 @@ def test_send_message_from_phonebook(harness, phone_number, sms_text): "numbers": [str(phone_number)], "priName": "Test"} ret = harness.endpoint_request("contacts", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] added_contact_id = ret["body"]["id"] # enter contacts (phonebook) menu @@ -443,7 +443,7 @@ def test_send_message_from_phonebook(harness, phone_number, sms_text): # removing added contact body = {"id": added_contact_id} ret = harness.endpoint_request("contacts", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] @pytest.mark.rt1051 @pytest.mark.usefixtures("phone_unlocked") @@ -463,7 +463,7 @@ def test_send_message_using_phonebook(harness, phone_number, sms_text): "numbers": [str(phone_number)], "priName": "Test"} ret = harness.endpoint_request("contacts", "put", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"] added_contact_id = ret["body"]["id"] # enter messages menu @@ -516,6 +516,6 @@ def test_send_message_using_phonebook(harness, phone_number, sms_text): # removing added contact body = {"id": added_contact_id} ret = harness.endpoint_request("contacts", "del", body) - assert ret["status"] == status["OK"] + assert ret["status"] == status["NoContent"]