~aleteoryx/muditaos

ref: 0e8b4c848e3f87f3bbb1f64ef7460cf56017b87f muditaos/test/pytest/test_cellular_sleep.py -rw-r--r-- 2.1 KiB
0e8b4c84 — Lefucjusz [BH-2108] Fix misaligned charging symbol 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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
from harness import log
from harness.interface.defs import status
from harness.interface.defs import key_codes
from test_call import  test_call as call
from test_send_message import test_send_prepared_message as send_prepared_message

def request_cellular_sleep_mode_info(harness):
    body = {"getInfo": "cellularSleepMode"}
    return harness.endpoint_request("developerMode", "get", body)
    

def wait_for_cellular_sleep(harness, max_attempts):
    for i in range(max_attempts):
        ret = request_cellular_sleep_mode_info(harness)
        assert ret["status"] == status["OK"]
        if  ret["body"]["cellularSleepMode"] == True:
            return True
        else:
            log.info("cellular is not in the sleep mode, waiting...")
            time.sleep(2)
    return False


@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_call_during_cellular_sleep_mode(harness, phone_number, call_duration, max_attempts = 10):
    cellular_sleep_mode = wait_for_cellular_sleep(harness, max_attempts)
    if (cellular_sleep_mode == False):
        log.warning("cellular is not in the sleep mode!")

    harness.unlock_phone()
    # try to make outgoing call
    call(harness, phone_number, call_duration)
    
    # cellular should be awake 
    ret = request_cellular_sleep_mode_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularSleepMode"] == False

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_sms_during_cellular_sleep_mode(harness, phone_number, sms_text, max_attempts = 10):
    cellular_sleep_mode = wait_for_cellular_sleep(harness, max_attempts)
    if (cellular_sleep_mode == False):
        log.warning("cellular is not in the sleep mode!")
    
    # send text message
    send_prepared_message(harness, phone_number, sms_text)
    
    # cellular should be awake 
    ret = request_cellular_sleep_mode_info(harness)
    assert ret["status"] == status["OK"]
    assert ret["body"]["cellularSleepMode"] == False