From cecfb8a00ebe0c947275370b4050ca6f41a9f9b4 Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Tue, 14 Feb 2023 13:28:50 +0100 Subject: [PATCH] [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. --- test/harness | 2 +- test/pytest/service-desktop/test_contacts.py | 10 +++++++++- test/pytest/service-desktop/test_message_threads.py | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/harness b/test/harness index 4da3642f7f1306c5d282f68d037bc7c260874ef1..e64ff2a5c44a6f44bd9faab539c09699935c9c8c 160000 --- a/test/harness +++ b/test/harness @@ -1 +1 @@ -Subproject commit 4da3642f7f1306c5d282f68d037bc7c260874ef1 +Subproject commit e64ff2a5c44a6f44bd9faab539c09699935c9c8c diff --git a/test/pytest/service-desktop/test_contacts.py b/test/pytest/service-desktop/test_contacts.py index 0ed0ed6e24d651bb0a27260dfbdf385f1c71495e..8a4f09060898446722a233bdf7af5dfafc68a789 100644 --- a/test/pytest/service-desktop/test_contacts.py +++ b/test/pytest/service-desktop/test_contacts.py @@ -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"] diff --git a/test/pytest/service-desktop/test_message_threads.py b/test/pytest/service-desktop/test_message_threads.py index 604f41a5168a1c46ba23b67008b0ed807a7694ca..9ffd51735e1535d09b6cfeb59fc92634d438ddac 100644 --- a/test/pytest/service-desktop/test_message_threads.py +++ b/test/pytest/service-desktop/test_message_threads.py @@ -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