~aleteoryx/muditaos

ref: 675dc59c9a8b57126de7e26c1bcb7d809358d130 muditaos/test/service-desktop-test/tests/calllog.py -rw-r--r-- 2.2 KiB
675dc59c — RobertPiet [EGD-3572] SettingsTable exchanged to settings::Settings (#968) (#1044) 5 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
50
51
52
53
54
55
56
57
58
59
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
from harness.interface.defs import endpoint, method, status

from test_api import *


class CalllogTest:
    def __init__(self, serial):
        self.serial = serial.get_serial()

    def run(self):

        msg, result_msg = prepare_message(endpoint["calllog"], method["get"], status["OK"], {"count": True})
        test = Test(self.serial, msg, result_msg)
        ret, result = test.execute()
        count = result["count"]
        if count == 0:
            print("count = 0!")
            return False

        msg, result_msg = prepare_message(endpoint["calllog"], method["get"], status["OK"], {"limit": count})
        test = Test(self.serial, msg, result_msg)
        ret, result = test.execute()
        contactId = result[0]["contactId"]
        if len(result) != count:
            print("record length mismatch!")
            return False

        for record in result:
            if record["phoneNumber"].isnumeric() == False:
                return False
            if record["date"].isnumeric() == False:
                return False
            if record["duration"].isnumeric() == False:
                return False

        msg, result_msg = prepare_message(endpoint["calllog"], method["get"], status["OK"], {"contactID": contactId})
        test = Test(self.serial, msg, result_msg)
        ret, calllog_result = test.execute()
        for calllog in calllog_result:
            if calllog["contactId"] != contactId:
                print("contactID mismatch!")
                return False

        msg, result_msg = prepare_message(endpoint["calllog"], method["del"], status["OK"], {"id": result[0]["id"]},None)
        test = Test(self.serial, msg, result_msg)
        ret, result = test.execute()
        if ret != True:
            return False

        msg, result_msg = prepare_message(endpoint["calllog"], method["get"], status["OK"], {"count": True})
        test = Test(self.serial, msg, result_msg)
        ret, result = test.execute()
        if count != result["count"]+1:
            print("record count after delete mismatch!")
            return False

        return True