~aleteoryx/muditaos

ref: 04111a6e7fc1ad1b53a3bcbabcfe0326e8625d0e muditaos/test/pytest/service-desktop/test_send_sms.py -rw-r--r-- 1.3 KiB
04111a6e — Marek Niepieklo [CP-857] Refactor test_messages.py and test_send_sms.py 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
# Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

import pytest
from harness.request import TransactionError
from harness.api.messages import AddMessage


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_send_sms_ok(harness, phone_number, sms_text):

    resp = AddMessage(str(phone_number), sms_text).run(harness)

    message = resp.message

    assert type(message["messageBody"]) == str
    assert message["messageBody"] == sms_text
    assert type(message["messageID"]) == int
    assert type(message["messageType"]) == int
    assert type(message["createdAt"]) == int
    assert type(message["threadID"]) == int


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_send_sms_too_long(harness, phone_number):
    # single msg is 67 chars max
    # we concatenate up to 7 msgs
    sms_text = ''
    for i in range(67*7):
        sms_text = sms_text + chr(48 + i % 10)

    ret = AddMessage(str(phone_number), sms_text).run(harness)

    sms_text = sms_text + "a"
    with pytest.raises(TransactionError, match=r".*" + str(Status.BadRequest.value) + ".*"):
        ret = AddMessage(str(phone_number), sms_text).run(harness)