M test/pytest/service-desktop/test_messages.py => test/pytest/service-desktop/test_messages.py +11 -3
@@ 4,7 4,6 @@
import pytest
from harness.interface.defs import status
-
MESSAGES_PAGE_SIZE = 4
@@ 19,6 18,15 @@ def test_get_messages_without_pagination(harness):
messages = ret["body"]["entries"]
messages_count = len(messages)
assert messages_count == limit
+ message_types = [1, 2, 4, 8, 16, 18, 255]
+ for message in messages:
+ assert type(message["contactID"]) == int
+ assert type(message["messageBody"]) == str
+ assert type(message["messageID"]) == int
+ assert type(message["messageType"]) == int
+ assert type(message["createdAt"]) == int
+ assert type(message["threadID"]) == int
+ assert message["messageType"] in message_types
@pytest.mark.service_desktop_test
@@ 61,7 69,7 @@ def test_get_all_messages(harness):
if "nextPage" in ret["body"]:
offset = ret["body"]["nextPage"]["offset"]
- messages_left_count = count - len(all_messages)
+ messages_left_count = count - len(all_messages)
body = {"category": "message", "limit": messages_left_count, "offset": offset}
ret = harness.endpoint_request("messages", "get", body)
@@ 136,7 144,7 @@ def test_get_all_messages_by_thread_id(harness):
if "nextPage" in ret["body"]:
offset = ret["body"]["nextPage"]["offset"]
- messages_left_count = messages_by_thread_id_count - len(all_messages)
+ messages_left_count = messages_by_thread_id_count - len(all_messages)
body = {"category": "message", "threadID": thread_id, "limit": messages_left_count, "offset": offset}
ret = harness.endpoint_request("messages", "get", body)
M test/pytest/service-desktop/test_templates.py => test/pytest/service-desktop/test_templates.py +4 -0
@@ 83,6 83,10 @@ class TemplatesTester:
assert ret["status"] == status["OK"]
assert ret["body"]["totalCount"] == count
assert len(ret["body"]["entries"]) == number_of_requested_templates
+ for template in ret["body"]["entries"]:
+ assert type(template["lastUsedAt"]) == int
+ assert type(template["templateBody"]) == str
+ assert type(template["templateID"]) == int
def test_changing_template_body(self):
test_passed = False
M test/pytest/service-desktop/test_threads.py => test/pytest/service-desktop/test_threads.py +13 -0
@@ 12,6 12,19 @@ def test_threads(harness):
ret = harness.endpoint_request("messages", "get", body)
assert ret["status"] == status["OK"]
+ # Check if all fields are present and have proper type
+ message_types = [1, 2, 4, 8, 16, 18, 255]
+ for thread in ret["body"]["entries"]:
+ assert type(thread["contactID"]) == int
+ assert type(thread["isUnread"]) == bool
+ assert type(thread["lastUpdatedAt"]) == int
+ assert type(thread["messageCount"]) == int
+ assert type(thread["messageSnippet"]) == str
+ assert type(thread["messageType"]) == int
+ assert type(thread["numberID"]) == int
+ assert type(thread["threadID"]) == int
+ assert thread["messageType"] in message_types
+
# getting a number of threads
number_of_requested_threads = 3
if ret["body"]["totalCount"] < number_of_requested_threads: