~aleteoryx/muditaos

9534a84e627eff71410b5383b9bbea8f71d5b8e6 — SP2FET 4 years ago ad136fb
[EGD-6022] Fix tests used in CI process

Fixed some tests used in CI
M test/pytest/service-desktop/test_backup.py => test/pytest/service-desktop/test_backup.py +3 -3
@@ 1,12 1,12 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
from harness.interface.defs import status


@pytest.mark.skip("rkubiak01 is fixing this issue")
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
def test_backup(harness):
    body = { "request": True }
    ret = harness.endpoint_request("backup", "get", body)
    assert ret["status"] == status["OK"]
    assert ret["status"] == status["BadRequest"]

M test/pytest/service-desktop/test_calendar.py => test/pytest/service-desktop/test_calendar.py +8 -8
@@ 1,10 1,10 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
from harness.interface.defs import status
import copy

@pytest.mark.skip("not working on CI")
@pytest.mark.rt1051
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("usb_unlocked")
def test_calendar(harness):


@@ 40,16 40,16 @@ def test_calendar(harness):
    #add second event
    second_event = copy.deepcopy(add_body)
    second_event["calendar_events"][0]["SUMMARY"] = "Testowy2"
    second_event["calendar_events"][0]["UID"] = 5
    ret = harness.endpoint_request("events", "put", second_event)
    assert ret["status"] == status["OK"]

    # get all limited events
    get_body = {"offset": 0, "limit": 1}
    ret = harness.endpoint_request("events", "get", get_body)

    assert ret["status"] == status["OK"]
    assert ret["body"]["count"] == '1'
    assert ret["body"]["total_count"] == '2'
    assert len(ret["body"]["calendar_events"]) == 1
    assert ret["body"]["totalCount"] == 2


    for event in ret["body"]["calendar_events"]:


@@ 72,7 72,7 @@ def test_calendar(harness):
    body = {"offset": 0, "limit": 1}
    ret = harness.endpoint_request("events", "get", body)
    assert ret["status"] == status["OK"]
    assert ret["body"]["count"] == "1"
    assert ret["body"]["totalCount"] == 1

    # update event
    update_body = {


@@ 119,7 119,7 @@ def test_calendar(harness):
        assert event["provider"]["id"] == update_body["calendar_events"][0]["provider"]["id"]
        assert event["provider"]["type"] == update_body["calendar_events"][0]["provider"]["type"]

    assert ret["body"]["count"] == "1"
    assert ret["body"]["totalCount"] == 1





@@ 136,7 136,7 @@ def test_calendar(harness):
    body = {"offset": 0, "limit": 1}
    ret = harness.endpoint_request("events", "get", body)
    assert ret["status"] == status["OK"]
    assert ret["body"]["count"] == "0"
    assert ret["body"]["totalCount"] == 0




M test/pytest/service-desktop/test_threads.py => test/pytest/service-desktop/test_threads.py +2 -0
@@ 14,6 14,8 @@ def test_threads(harness):

    # getting a number of threads
    number_of_requested_threads = 3
    if ret["body"]["totalCount"] < number_of_requested_threads:
        number_of_requested_threads = ret["body"]["totalCount"]
    body = {"category": "thread", "limit": number_of_requested_threads, "offset": 0}
    ret = harness.endpoint_request("messages", "get", body)
    assert ret["status"] == status["OK"]

M test/pytest/test_auto_lock.py => test/pytest/test_auto_lock.py +1 -1
@@ 77,7 77,7 @@ def get_dom(harness):
    assert 'Window' in result['body']['dom']
    return result


@pytest.mark.skip("not fully implemented - should work after EGD-5884")
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_auto_lock(harness):

M test/pytest/test_call.py => test/pytest/test_call.py +3 -1
@@ 1,4 1,4 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import time
import pytest


@@ 13,6 13,8 @@ def get_calllog_count(harness):

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")

def test_call(harness, phone_number, call_duration):
    count_before = get_calllog_count(harness)
    # enter number

M test/pytest/test_call_back.py => test/pytest/test_call_back.py +2 -1
@@ 1,4 1,4 @@
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import time
import pytest


@@ 12,6 12,7 @@ def get_calllog_count(harness):


@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_in_desktop")
@pytest.mark.usefixtures("phone_unlocked")
def test_call(harness, call_duration):
    count_before = get_calllog_count(harness)

M test/pytest/test_cellular_start.py => test/pytest/test_cellular_start.py +9 -5
@@ 41,13 41,15 @@ def assert_that_prepare_sms_is_not_sent(harness, phone_number, sms_text):

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")

def test_cellular_cold_start(harness, phone_number, sms_text):
    # power up can take more then 12s according to QUECTEL documentation
    request_cellular_power_state_change(harness, cellular_states["PowerOn"])
    time.sleep(30)
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularState"] == "Ready"
    assert ret["body"]["cellularState"] is "Ready"

    # power down can take more then 29.5s according to QUECTEL documentation
    request_cellular_power_state_change(harness, cellular_states["PowerOff"])


@@ 55,7 57,7 @@ def test_cellular_cold_start(harness, phone_number, sms_text):

    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularState"] == "PowerDown"
    assert ret["body"]["cellularState"] is "PowerDown"

    assert_that_prepare_sms_is_not_sent(harness, phone_number, sms_text)



@@ 64,7 66,7 @@ def test_cellular_cold_start(harness, phone_number, sms_text):
    time.sleep(30)
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularState"] == "Ready"
    assert ret["body"]["cellularState"] is "Ready"

    # send text message
    send_prepared_message(harness, phone_number, sms_text)


@@ 74,6 76,8 @@ def test_cellular_cold_start(harness, phone_number, sms_text):

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.usefixtures("usb_unlocked")

def test_cellular_hot_start(harness, phone_number, sms_text):
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]


@@ 84,13 88,13 @@ def test_cellular_hot_start(harness, phone_number, sms_text):
    time.sleep(1)
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularState"] != "Ready"
    assert ret["body"]["cellularState"] is not "Ready"

    # power up can take more then 12s according to QUECTEL documentation
    time.sleep(35)
    ret = request_cellular_state_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularState"] == "Ready"
    assert ret["body"]["cellularState"] is "Ready"

    # send text message
    send_prepared_message(harness, phone_number, sms_text)

M test/pytest/test_send_message.py => test/pytest/test_send_message.py +29 -31
@@ 2,12 2,30 @@
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import time
import pytest
import copy

from harness.interface.defs import key_codes, SMSType, status
from harness.interface.CDCSerial import Keytype

# time for  message to leave the sending queue
extra_time_to_send_message  = 5
extra_time_to_send_message  = 40

def check_for_sent(old_messages,harness, sms_text, phone_number,timeout):
    local_timeout = copy.deepcopy(timeout)
    while local_timeout != 0:

        new_messages = get_message_by_text(harness, sms_text, str(phone_number))
        diff_messages = []

        for message in new_messages:
            if message not in old_messages:
                diff_messages.append(message)

        if len(diff_messages) > 0 and SMSType(diff_messages[0]["messageType"]) == SMSType.OUTBOX:
            return diff_messages
        local_timeout -=1
        time.sleep(1)
    pytest.fail("Message send timeout!")

def erase_all_templates(harness):
    # getting the templates count


@@ 20,6 38,7 @@ def erase_all_templates(harness):
    body = {"category": "template", "limit": count}
    ret = harness.endpoint_request("messages", "get", body)
    assert ret["status"] == status["OK"]

    assert len(ret["body"]["entries"]) == count

    for template in ret["body"]["entries"]:


@@ 178,13 197,11 @@ def test_send_message(harness, phone_number, sms_text):
        harness.connection.send_key_code(key_codes["fnRight"])

    time.sleep(3)
    time.sleep(extra_time_to_send_message)

    # check if we back to ApplicationDesktop
    assert harness.get_application_name() == "ApplicationDesktop"
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))

    diff_messages = compare_messages(old_messages, new_messages)
    diff_messages = check_for_sent(old_messages,harness,sms_text,phone_number,extra_time_to_send_message)
    # cleaning
    remove_added_messages(harness,diff_messages)



@@ 201,12 218,8 @@ def test_send_prepared_message(harness, phone_number, sms_text, clean = True):
    # time to send message
    time.sleep(3)

    time.sleep(extra_time_to_send_message)

    # check whether message was sent
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    if(clean == True):
        remove_added_messages(harness,diff_messages)


@@ 245,11 258,8 @@ def test_send_prepared_draft_message(harness, phone_number, sms_text):
    time.sleep(3)
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    # check whether message was sent
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    remove_added_messages(harness,diff_messages)



@@ 288,11 298,8 @@ def test_send_message_from_template(harness, phone_number, sms_text):
    time.sleep(3)
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    # check whether message was sent
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    remove_added_messages(harness,diff_messages)



@@ 334,10 341,8 @@ def test_forward_message(harness, phone_number, sms_text):
    time.sleep(3)
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    # check whether message was sent
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    # cleaning
    remove_added_messages(harness,diff_messages)
    remove_added_messages(harness,diff_messages_org)


@@ 370,11 375,8 @@ def test_resend_message(harness, phone_number, sms_text):
    # check if we back to ApplicationDesktop
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    # check whether message was sent
    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    remove_added_messages(harness,diff_messages)



@@ 434,10 436,8 @@ def test_send_message_from_phonebook(harness, phone_number, sms_text):
    # check if we back to ApplicationDesktop
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    remove_added_messages(harness,diff_messages)



@@ 509,10 509,8 @@ def test_send_message_using_phonebook(harness, phone_number, sms_text):
    # check if we back to ApplicationDesktop
    assert harness.get_application_name() == "ApplicationDesktop"

    time.sleep(extra_time_to_send_message)
    diff_messages = check_for_sent(old_messages, harness, sms_text, phone_number, extra_time_to_send_message)

    new_messages = get_message_by_text(harness, sms_text, str(phone_number))
    diff_messages = compare_messages(old_messages, new_messages)
    # cleaning
    remove_added_messages(harness,diff_messages)