test_: Code Migration from status-cli-tests logger removal

This commit is contained in:
shashankshampi 2024-11-02 20:30:18 +05:30
parent 670f17a25f
commit 26adbea3df
2 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import json import json
import logging
import time import time
from src.libs.common import write_signal_to_file from src.libs.common import write_signal_to_file
@ -33,7 +32,7 @@ class SignalClient:
raise TimeoutError( raise TimeoutError(
f"Signal {signal_type} is not received in {timeout} seconds") f"Signal {signal_type} is not received in {timeout} seconds")
time.sleep(0.2) time.sleep(0.2)
logging.debug(f"Signal {signal_type} is received in {round(time.time() - start_time)} seconds") logger.debug(f"Signal {signal_type} is received in {round(time.time() - start_time)} seconds")
return self.received_signals[signal_type][0] return self.received_signals[signal_type][0]
def wait_for_complete_signal(self, signal_type, timeout=5): def wait_for_complete_signal(self, signal_type, timeout=5):
@ -47,7 +46,7 @@ class SignalClient:
time.sleep(0.2) time.sleep(0.2)
if events: if events:
logging.debug( logger.debug(
f"Collected {len(events)} events of type {signal_type} within {timeout} seconds") f"Collected {len(events)} events of type {signal_type} within {timeout} seconds")
return events return events
raise TimeoutError(f"No signals of type {signal_type} received in {timeout} seconds") raise TimeoutError(f"No signals of type {signal_type} received in {timeout} seconds")

View File

@ -1,4 +1,3 @@
import logging
from uuid import uuid4 from uuid import uuid4
from constants import * from constants import *
from src.libs.common import delay from src.libs.common import delay
@ -10,6 +9,7 @@ from validators.contact_request_validator import ContactRequestValidator
logger = get_custom_logger(__name__) logger = get_custom_logger(__name__)
class TestContactRequest(StepsCommon): class TestContactRequest(StepsCommon):
def test_contact_request_baseline(self): def test_contact_request_baseline(self):
timeout_secs = 3 timeout_secs = 3
@ -112,7 +112,7 @@ class TestContactRequest(StepsCommon):
) )
break break
except AssertionError as validation_error: except AssertionError as validation_error:
logging.error(f"Validation failed for event: {messages_new_event}, Error: {validation_error}") logger.error(f"Validation failed for event: {messages_new_event}, Error: {validation_error}")
continue continue
if messages_new_event is None: if messages_new_event is None:
@ -120,7 +120,7 @@ class TestContactRequest(StepsCommon):
first_node.wait_for_signal("history.request.completed", timeout) first_node.wait_for_signal("history.request.completed", timeout)
except (TimeoutError, ValueError) as e: except (TimeoutError, ValueError) as e:
logging.error(f"Signal validation failed: {str(e)}") logger.error(f"Signal validation failed: {str(e)}")
return timestamp, message_id, contact_request_message, None return timestamp, message_id, contact_request_message, None
first_node.stop() first_node.stop()