~aleteoryx/muditaos

cecfb8a00ebe0c947275370b4050ca6f41a9f9b4 — Lukasz Mastalerz 2 years ago 1340e69
[CP-1624] Cover new fields in contact and message endpoints with tests

Cover new fields for holding numberID in contact and message endpoint
response to keep the integrity and test passing.
M test/harness => test/harness +1 -1
@@ 1,1 1,1 @@
Subproject commit 4da3642f7f1306c5d282f68d037bc7c260874ef1
Subproject commit e64ff2a5c44a6f44bd9faab539c09699935c9c8c

M test/pytest/service-desktop/test_contacts.py => test/pytest/service-desktop/test_contacts.py +9 -1
@@ 39,7 39,7 @@ class ContactsTester:
        try:
            contact_id = AddContact(contact_record).run(self.harness).id
        except TransactionError:
            return False
            return False, -1
        else:
            return True, contact_id



@@ 98,6 98,7 @@ def test_add_single_contact(harness):
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(contact_id)
    assert result, "Failed to get contact by ID!"
    del retrieved_contact_record["id"]
    contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert contact_record == retrieved_contact_record, "Received contact record is different than expected!"

    # Clean up


@@ 189,6 190,7 @@ def test_edit_contact(harness):
    }
    assert contacts_tester.update_contact(edited_contact_record), "Failed to update contact!"
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(contact_id)
    edited_contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert result, "Failed to get contact by ID!"
    assert retrieved_contact_record == edited_contact_record



@@ 229,6 231,7 @@ def test_add_and_get_multiple_contacts(harness):
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(first_contact_id)
    assert result, "Failed to get contact by ID!"
    del retrieved_contact_record["id"]
    first_contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert first_contact_record == retrieved_contact_record, "Received contact record is different than expected!"
    current_number_of_contact_records = initial_number_of_contact_records + 1



@@ 252,6 255,7 @@ def test_add_and_get_multiple_contacts(harness):
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(second_contact_id)
    assert result, "Failed to get contact by ID!"
    del retrieved_contact_record["id"]
    second_contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert second_contact_record == retrieved_contact_record, "Received contact record is different than expected!"
    current_number_of_contact_records += 1



@@ 275,6 279,7 @@ def test_add_and_get_multiple_contacts(harness):
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(third_contact_id)
    assert result, "Failed to get contact by ID!"
    del retrieved_contact_record["id"]
    third_contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert third_contact_record == retrieved_contact_record, "Received contact record is different than expected!"
    current_number_of_contact_records += 1



@@ 298,6 303,7 @@ def test_add_and_get_multiple_contacts(harness):
    result, retrieved_contact_record = contacts_tester.get_contact_by_id(fourth_contact_id)
    assert result, "Failed to get contact by ID!"
    del retrieved_contact_record["id"]
    fourth_contact_record["numbersIDs"] = retrieved_contact_record["numbersIDs"]
    assert fourth_contact_record == retrieved_contact_record, "Received contact record is different than expected!"
    current_number_of_contact_records += 1



@@ 311,6 317,8 @@ def test_add_and_get_multiple_contacts(harness):
        initial_number_of_contact_records, current_number_of_contact_records - initial_number_of_contact_records)
    assert result, "Failed to get contacts with offset and limit!"

    # This section requires to have empty phonebook
    # TO DO: fix it to work with any number of contacts in phonebook
    for record in returned_contacts:
        print(record)
        del record["id"]

M test/pytest/service-desktop/test_message_threads.py => test/pytest/service-desktop/test_message_threads.py +4 -1
@@ 2,7 2,8 @@
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import pytest
from harness.request import TransactionError
from harness.api.messages import GetThreadsWithOffsetAndLimit, GetThreadById, MarkThreadAsUnread, DeleteThreadById, GetMessageById, AddMessage, DeleteMessageById
from harness.api.messages import GetThreadsWithOffsetAndLimit, GetThreadById, MarkThreadAsUnread, DeleteThreadById, \
    GetMessageById, AddMessage, DeleteMessageById


class ThreadsTester:


@@ 81,6 82,7 @@ def test_create_and_delete_thread(harness):

    assert threads_tester.delete_thread_by_id(message_record["threadID"]), "Failed to delete a thread!"


@pytest.mark.service_desktop_test
@pytest.mark.usefixtures("phone_unlocked")
def test_marking_thread_as_read(harness):


@@ 137,6 139,7 @@ def test_getting_threads(harness):
        assert type(thread["messageSnippet"]) == str
        assert type(thread["messageType"]) == int
        assert type(thread["number"]) == str
        assert type(thread["numberID"]) == str
        assert type(thread["threadID"]) == int
        message_types = [1, 2, 4, 8, 16, 18, 255]
        assert thread["messageType"] in message_types