~aleteoryx/muditaos

ref: 39255b2d45ffacb9de27d211c79d6a6763d69bcf muditaos/test/pytest/service-desktop/test_restore.py -rw-r--r-- 1.5 KiB
39255b2d — Paweł Joński [BH-743] AlarmEvent UT 4 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
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
import time
from harness.interface.defs import status
from harness import log


@pytest.mark.service_desktop_test
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
@pytest.mark.restore
def test_restore(harness):
    # this requests the list of available files
    body = { "request": True }
    response = harness.endpoint_request("restore", "get", body)
    
    # should be ok 200
    assert response["status"] == status["OK"]
    log.debug("check if body is an array")
    
    # body should be an array of files
    assert isinstance(response["body"], list) == True
    
    # chose the first entry for test if array is > 0
    if len(response["body"]) > 0:
        restore_task = response["body"][0]
        log.debug("there are possible backup files on target, test restore %s" % (restore_task))
        # this starts a restore process with a file as parameter
        body = { "request":True, "location": restore_task }
        response = harness.endpoint_request("restore", "post", body)
        
        # we can't really test for results here, as the phone should reset
        # in case the restore process lasts longer we should be able to poll
        # but only on rt1051
        assert response["body"]["location"] != ""
        assert response["body"]["state"] != ""
    else:
        log.error("no possisble backup files on phone, run backup first")
        assert False