~aleteoryx/muditaos

0c76e7650f89ef5fbe7f6119059a84f0ab127c3a — Marek Niepieklo 4 years ago 97f79cf
[CP-914] Update factory reset test

Moved the test out form pytest/service-desktop
Improved test scenario to check for the onboarding screen
Used Factory Reset API for Harness
3 files changed, 36 insertions(+), 15 deletions(-)

M test/harness
D test/pytest/service-desktop/test_factory_reset.py
A test/pytest/test_factory_reset.py
M test/harness => test/harness +1 -1
@@ 1,1 1,1 @@
Subproject commit 4e0d27c1c3f0298ac164efe696cad5abb66c94bf
Subproject commit 334abdbf10a67216f98bbe57b25e231dfebde720

D test/pytest/service-desktop/test_factory_reset.py => test/pytest/service-desktop/test_factory_reset.py +0 -14
@@ 1,14 0,0 @@
# 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.service_desktop_test
@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_factory_reset(harness):
    body = {"factoryRequest": True}
    ret = harness.endpoint_request("factory", "post", body)
    assert ret["status"] == status["OK"]
    assert ret["body"] == body

A test/pytest/test_factory_reset.py => test/pytest/test_factory_reset.py +35 -0
@@ 0,0 1,35 @@
# 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 import log
from harness.utils import Timeout
from harness.interface.defs import status
from harness.api.factory import FactoryReset
from harness.rt_harness_discovery import get_harness_automatic

def phone_in_onboarding(harness):

    # assert that we are in ApplicationOnBoarding
    log.debug("Assert that we are in ApplicationOnBoarding")
    assert harness.get_application_name() == "ApplicationOnBoarding"

@pytest.mark.rt1051
@pytest.mark.usefixtures("phone_unlocked")
def test_factory_reset(harness):
    ret = FactoryReset().run(harness)

    assert ret.requestDone == True

    try:
        with Timeout.limit(seconds=30):
            log.info("Please, power-cycle the DUT")
            harness.connection.watch_port_reboot(20)
            harness = get_harness_automatic(20)
    except Timeout as e:
        log.error("Factory reset timeout reached")

    time.sleep(5)  # wait for the DUT to be ready

    phone_in_onboarding(harness)