~aleteoryx/muditaos

f8c39b30d66bf275994d8c137219de2c9b965226 — Pawel Olejniczak 4 years ago 266c208
[CP-142] Update tests with 204 response code

Uptdate python test scripts with 204 (NoContent) code
for responsens with empty body.
M test/pytest/service-desktop/test_calendar.py => test/pytest/service-desktop/test_calendar.py +3 -3
@@ 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}

M test/pytest/service-desktop/test_calendar_events.py => test/pytest/service-desktop/test_calendar_events.py +3 -3
@@ 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"]



M test/pytest/service-desktop/test_calllog.py => test/pytest/service-desktop/test_calllog.py +1 -1
@@ 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}

M test/pytest/service-desktop/test_contacts.py => test/pytest/service-desktop/test_contacts.py +2 -2
@@ 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}

M test/pytest/service-desktop/test_messages.py => test/pytest/service-desktop/test_messages.py +1 -1
@@ 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}

M test/pytest/service-desktop/test_security.py => test/pytest/service-desktop/test_security.py +5 -5
@@ 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)


M test/pytest/service-desktop/test_templates.py => test/pytest/service-desktop/test_templates.py +3 -3
@@ 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"])

M test/pytest/service-desktop/test_threads.py => test/pytest/service-desktop/test_threads.py +1 -1
@@ 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"]

M test/pytest/test_auto_lock.py => test/pytest/test_auto_lock.py +1 -1
@@ 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):

M test/pytest/test_change_sim.py => test/pytest/test_change_sim.py +2 -2
@@ 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)

M test/pytest/test_send_message.py => test/pytest/test_send_message.py +9 -9
@@ 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"]