From ffd8d5b197bbfd186033ac25fc5b6163757a0d90 Mon Sep 17 00:00:00 2001 From: aya Date: Tue, 22 Oct 2024 11:58:50 +0300 Subject: [PATCH] fixing review comments --- src/node/store_response.py | 10 ++++++++++ tests/store/test_api_flags.py | 14 +------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/node/store_response.py b/src/node/store_response.py index 7e168ba5..d6274ce7 100644 --- a/src/node/store_response.py +++ b/src/node/store_response.py @@ -69,6 +69,16 @@ class StoreResponse: except IndexError: return None + def message_payload(self, index): + try: + if self.messages is not None: + payload = self.messages[index]["message"]["payload"] + return payload + else: + return None + except IndexError: + return None + def message_at(self, index): try: if self.messages is not None: diff --git a/tests/store/test_api_flags.py b/tests/store/test_api_flags.py index 674cf19a..1bfe7b80 100644 --- a/tests/store/test_api_flags.py +++ b/tests/store/test_api_flags.py @@ -68,23 +68,11 @@ class TestApiFlags(StepsStore): logger.debug(f" Message restored with hash only is {store_response.messages} ") assert "message" not in store_response.messages - def test_get_store_messages_with_different_pubsub_topics11(self): - wrong_topic = PUBSUB_TOPICS_STORE[0][:-1] - logger.debug(f"Trying to get stored msg with wrong topic") - try: - self.publish_message(pubsub_topic=PUBSUB_TOPICS_STORE[0]) - self.check_published_message_is_stored(pubsub_topic=wrong_topic) - raise Exception("Message stored with wrong peer topic") - except Exception as e: - logger.error(f"Topic {wrong_topic} is wrong ''n: {str(e)}") - assert e.args[0].find("messages': []") != -1, "Message shall not be stored for wrong topic" - def test_get_store_messages_with_content_topic(self): # positive scenario content_topic = "/myapp/1/latest/protoo" - message = {"payload": to_base64(self.test_payload), "" "contentTopic": content_topic, "timestamp": int(time() * 1e9)} logger.debug(f"Trying to publish msg with content topic {content_topic}") - msg = self.publish_message(message=message) + msg = self.publish_message(message=self.create_message(contentTopic=content_topic)) store_response = self.get_messages_from_store(self.store_node1, include_data="true", content_topics=content_topic) try: if store_response.messages is not None: