~aleteoryx/muditaos

ref: 950cf78aa9fe3f30d25d5048f0ec46bf5fe2eac0 muditaos/test/pytest/service-desktop/test_device_info.py -rw-r--r-- 2.5 KiB
950cf78a — Lukasz Mastalerz [CP-1825] Update while on onboarding screen 2 years 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
# Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
import re
from harness.api.device_info import GetDeviceInfo, GetDiagnosticFilesList, DiagnosticsFileList


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_get_device_information(harness):
    ret = GetDeviceInfo().run(harness)
    assert int(ret.diag_info["batteryLevel"]) <= 100
    assert ret.diag_info["batteryState"] in ['1', '2']
    assert ret.diag_info["selectedSim"] in ['0', '1', '4']
    assert ret.diag_info["trayState"] == '1'
    assert 0 <= int(ret.diag_info["signalStrength"]) < 5
    assert ret.diag_info["accessTechnology"] in ['0', '2', '3', '4', '5', '6', '7', '255']
    assert 0 <= int(ret.diag_info["networkStatus"]) < 7
    assert ret.diag_info["networkOperatorName"] is not None
    assert 0 < int(ret.diag_info["usedUserSpace"]) <= 12903
    assert int(ret.diag_info["systemReservedSpace"]) == 2048
    assert int(ret.diag_info["deviceSpaceTotal"]) == (12903 + 2048)  # User + system partitions sizes
    assert re.match(r"^(\d|[a-z]){8,40}$", ret.diag_info["gitRevision"])
    assert ret.diag_info["gitBranch"] is not None
    assert int(ret.diag_info["currentRTCTime"]) > 1641991996
    assert re.match(r"^\d\.\d\.\d", ret.diag_info["version"])
    assert re.match(r"^\d{3,14}$", ret.diag_info["serialNumber"])
    assert ret.diag_info["caseColour"] in ["gray", "black"]
    assert ret.diag_info["recoveryStatusFilePath"] == "/user/temp/recovery_status.json"
    assert ret.diag_info["updateFilePath"] == "/user/temp/update.tar"
    assert ret.diag_info["backupFilePath"] == "/user/temp/backup.tar"
    assert ret.diag_info["syncFilePath"] == "/user/temp/sync.tar"
    assert re.match(r"^(\d|[a-zA-Z]){32}$", ret.diag_info["deviceToken"])
    assert ret.diag_info["onboardingState"] in ["0", "1"]


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_get_list_of_log_files(harness):
    ret = GetDiagnosticFilesList(DiagnosticsFileList.LOGS).run(harness)
    assert "/system/log/MuditaOS.log" in ret.files


@pytest.mark.skip(reason="Deactivated until we have possibility to generate crash dumps on demand [CP-690]")
@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_get_list_of_crash_dump_files(harness):
    ret = GetDiagnosticFilesList(DiagnosticsFileList.CRASH_DUMPS).run(harness)
    assert "/system/crash_dumps/crashdump.hex" in ret.files