-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_: contact requests tests (#6167)
test_: fewer nodes for multiple_contact_requests test test_: fewer nodes for multiple_contact_requests test test_: skip multiple_contact_requests test test_: address review comments test_: check messages just in event/messages test_: get expected message by content type test_: address review comments
- Loading branch information
Showing
6 changed files
with
161 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from enum import Enum | ||
|
||
class MessageContentType(Enum): | ||
UNKNOWN_CONTENT_TYPE = 0 | ||
TEXT_PLAIN = 1 | ||
STICKER = 2 | ||
STATUS = 3 | ||
EMOJI = 4 | ||
TRANSACTION_COMMAND = 5 | ||
SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP = 6 | ||
IMAGE = 7 | ||
AUDIO = 8 | ||
COMMUNITY = 9 | ||
SYSTEM_MESSAGE_GAP = 10 | ||
CONTACT_REQUEST = 11 | ||
DISCORD_MESSAGE = 12 | ||
IDENTITY_VERIFICATION = 13 | ||
SYSTEM_MESSAGE_PINNED_MESSAGE = 14 | ||
SYSTEM_MESSAGE_MUTUAL_EVENT_SENT = 15 | ||
SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED = 16 | ||
SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED = 17 | ||
BRIDGE_MESSAGE = 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from time import sleep | ||
from uuid import uuid4 | ||
import pytest | ||
from test_cases import OneToOneMessageTestCase | ||
from constants import DEFAULT_DISPLAY_NAME | ||
from clients.signals import SignalType | ||
from resources.enums import MessageContentType | ||
|
||
@pytest.mark.rpc | ||
class TestContactRequests(OneToOneMessageTestCase): | ||
|
||
|
||
@pytest.mark.dependency(name="test_contact_request_baseline") | ||
def test_contact_request_baseline(self, execution_number=1): | ||
|
||
await_signals = [ | ||
SignalType.MESSAGES_NEW.value, | ||
SignalType.MESSAGE_DELIVERED.value, | ||
] | ||
|
||
message_text = f"test_contact_request_{execution_number}_{uuid4()}" | ||
|
||
sender = self.initialize_backend(await_signals=await_signals) | ||
receiver = self.initialize_backend(await_signals=await_signals) | ||
|
||
pk_sender = sender.get_pubkey(DEFAULT_DISPLAY_NAME) | ||
pk_receiver = receiver.get_pubkey(DEFAULT_DISPLAY_NAME) | ||
|
||
existing_contacts = receiver.get_contacts() | ||
|
||
if pk_sender in str(existing_contacts): | ||
pytest.skip("Contact request was already sent for this sender<->receiver. Skipping test!!") | ||
|
||
response = sender.send_contact_request(pk_receiver, message_text) | ||
expected_message = self.get_message_by_content_type(response, content_type=MessageContentType.CONTACT_REQUEST.value) | ||
|
||
messages_new_event = receiver.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=expected_message.get("id"), timeout=60) | ||
|
||
signal_messages_texts = [] | ||
if "messages" in messages_new_event.get("event", {}): | ||
signal_messages_texts.extend( | ||
message["text"] | ||
for message in messages_new_event["event"]["messages"] | ||
if "text" in message | ||
) | ||
|
||
assert f"@{pk_sender} sent you a contact request" in signal_messages_texts, "Couldn't find the signal corresponding to the contact request" | ||
|
||
self.validate_signal_event_against_response( | ||
signal_event=messages_new_event, | ||
fields_to_validate={"text": "text"}, | ||
expected_message=expected_message | ||
) | ||
|
||
@pytest.mark.skip(reason="Skipping because of error 'Not enough status-backend containers, please add more'. Unkipping when we merge https://github.com/status-im/status-go/pull/6159") | ||
@pytest.mark.parametrize("execution_number", range(10)) | ||
@pytest.mark.dependency(depends=["test_contact_request_baseline"]) | ||
def test_multiple_contact_requests(self, execution_number): | ||
self.test_contact_request_baseline(execution_number=execution_number) | ||
|
||
@pytest.mark.dependency(depends=["test_contact_request_baseline"]) | ||
@pytest.mark.skip(reason="Skipping until add_latency is implemented") | ||
def test_contact_request_with_latency(self): | ||
with self.add_latency(): | ||
self.test_contact_request_baseline() | ||
|
||
@pytest.mark.dependency(depends=["test_contact_request_baseline"]) | ||
@pytest.mark.skip(reason="Skipping until add_packet_loss is implemented") | ||
def test_contact_request_with_packet_loss(self): | ||
with self.add_packet_loss(): | ||
self.test_contact_request_baseline() | ||
|
||
@pytest.mark.dependency(depends=["test_contact_request_baseline"]) | ||
@pytest.mark.skip(reason="Skipping until add_low_bandwith is implemented") | ||
def test_contact_request_with_low_bandwidth(self): | ||
with self.add_low_bandwith(): | ||
self.test_contact_request_baseline() | ||
|
||
@pytest.mark.dependency(depends=["test_contact_request_baseline"]) | ||
@pytest.mark.skip(reason="Skipping until node_pause is implemented") | ||
def test_contact_request_with_node_pause_30_seconds(self): | ||
await_signals = [ | ||
SignalType.MESSAGES_NEW.value, | ||
SignalType.MESSAGE_DELIVERED.value, | ||
] | ||
sender = self.initialize_backend(await_signals=await_signals) | ||
receiver = self.initialize_backend(await_signals=await_signals) | ||
pk_receiver = receiver.get_pubkey(DEFAULT_DISPLAY_NAME) | ||
|
||
with self.node_pause(receiver): | ||
message_text = f"test_contact_request_{uuid4()}" | ||
sender.send_contact_request(pk_receiver, message_text) | ||
sleep(30) | ||
receiver.find_signal_containing_pattern(SignalType.MESSAGES_NEW.value, event_pattern=message_text) | ||
sender.wait_for_signal("messages.delivered") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters