~aleteoryx/muditaos

ref: 6a7d0a4ee2a095411b8bf106a7d07a9bae283093 muditaos/test/pytest/service-desktop/test_send_sms.py -rw-r--r-- 1.5 KiB
6a7d0a4e — Bartosz Cichocki [EGD-8059] Add verbosity to GH checks 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
41
42
43
44
# 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.usefixtures("phone_unlocked")
def test_send_sms_ok(harness, phone_number, sms_text):
    body = {"category": "message", "number": str(phone_number), "messageBody": sms_text}
    ret = harness.endpoint_request("messages", "post", body)

    assert ret["status"] == status["OK"]

    res_body = ret["body"]
    assert type(res_body["contactID"]) == int
    assert type(res_body["messageBody"]) == str
    assert res_body["messageBody"] == sms_text
    assert type(res_body["messageID"]) == int
    assert type(res_body["messageType"]) == int
    assert type(res_body["createdAt"]) == int
    assert type(res_body["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)

    body = {"category": "message", "number": str(phone_number), "messageBody": sms_text}
    ret = harness.endpoint_request("messages", "post", body)
    assert ret["status"] == status["OK"]

    sms_text = sms_text + 'a'
    body = {"category": "message", "number": str(phone_number), "messageBody": sms_text}
    ret = harness.endpoint_request("messages", "post", body)
    assert ret["status"] == status["BadRequest"]