test_: Code Migration from status-cli-tests with cleanup

This commit is contained in:
shashankshampi 2024-10-30 21:24:57 +05:30
parent 5b374662d6
commit c8256c234b
3 changed files with 8 additions and 61 deletions

View File

@ -1,56 +1,6 @@
anyio==4.6.0
attrs==23.1.0
black==24.3.0
certifi==2023.11.17
cfgv==3.4.0
charset-normalizer==3.3.2
click==8.1.7
clients==1.5
deepdiff==5.5.0
distlib==0.3.8
exceptiongroup==1.2.2
execnet==2.0.2
filelock==3.13.1
genson==1.2.2
h11==0.14.0
httpcore==1.0.6
httpx==0.27.2
identify==2.5.33
idna==3.7
importlib_metadata==8.5.0
iniconfig==2.0.0
jsonschema==3.2.0
libs==0.0.10
mypy-extensions==1.0.0
nodeenv==1.8.0
ordered-set==4.0.2
packaging==23.2
pathspec==0.12.1
platformdirs==4.1.0
pluggy==1.5.0
pre-commit==3.6.2
py==1.11.0
pyright==1.1.352
pyrsistent==0.20.0
pytest==8.3.3
pytest-dependency==0.6.0
pytest-instafail==0.5.0
pytest-rerunfailures==13.0
pytest-timeout==2.2.0
pytest-xdist==3.5.0
python-dotenv==1.0.1
PyYAML==6.0.1
requests==2.31.0
signals==0.0.2
six==1.16.0
sniffio==1.3.1
pytest==6.2.4
Requests==2.32.3
tenacity==8.2.3
toml==0.10.2
tomli==2.0.2
typeguard==4.1.5
typing-inspect==0.9.0
typing_extensions==4.9.0
urllib3==2.1.0
virtualenv==20.25.0
websocket-client==1.4.2
zipp==3.20.2
websocket_client==1.4.2

View File

@ -14,13 +14,14 @@ class TestContactRequest(StepsCommon):
num_contact_requests = NUM_CONTACT_REQUESTS
project_root = get_project_root()
nodes = []
LOCAL_DATA = "tests-functional/local"
for index in range(num_contact_requests):
first_node = StatusNode(name=f"first_node_{index}")
second_node = StatusNode(name=f"second_node_{index}")
data_dir_first = create_unique_data_dir(os.path.join(project_root, "tests-functional/local"), index)
data_dir_second = create_unique_data_dir(os.path.join(project_root, "tests-functional/local"), index)
data_dir_first = create_unique_data_dir(os.path.join(project_root, LOCAL_DATA), index)
data_dir_second = create_unique_data_dir(os.path.join(project_root, LOCAL_DATA), index)
delay(2)
first_node.start(data_dir=data_dir_first)

View File

@ -4,7 +4,6 @@ from src.steps.common import logger
class ContactRequestValidator:
"""Validator class for contact request responses."""
def __init__(self, response):
self.response = response
@ -15,22 +14,19 @@ class ContactRequestValidator:
assert "result" in self.response, "Missing 'result' in response"
def validate_chat_data(self, expected_chat_id, expected_display_name, expected_text):
"""Validate the chat data fields in the response."""
chats = self.response["result"].get("chats", [])
assert len(chats) > 0, "No chats found in the response"
chat = chats[0] # Validate the first chat as an example
chat = chats[0]
assert chat.get("id") == expected_chat_id, f"Chat ID mismatch: Expected {expected_chat_id}"
assert chat.get("name").startswith("0x"), "Invalid chat name format"
last_message = chat.get("lastMessage", {})
# assert last_message.get("displayName") == expected_display_name, "Display name mismatch"
assert last_message.get("text") == expected_text, "Message text mismatch"
assert last_message.get("contactRequestState") == 1, "Unexpected contact request state"
assert "compressedKey" in last_message, "Missing 'compressedKey' in last message"
def run_all_validations(self, expected_chat_id, expected_display_name, expected_text):
"""Run all validation methods for the contact request response."""
self.validate_response_structure()
self.validate_chat_data(expected_chat_id, expected_display_name, expected_text)
logger.info("All validations passed for the contact request response.")
logger.info("All validations passed for the contact request response.")