waku-interop-tests/tests/store/test_page_size.py
AYAHASSAN287 bd187ad118
adding test "test_store_not_include_data" (#76)
* adding test "test_store_not_include_data"

* adding test case for wrong peer address formatting

* try restore message with wrong peer id

* send peer address with wrong protocol

* Fixing review comments & add test for wrong topic

* adding test for topic content positive scenario

* adding test for different wrong content topic

* adding content topic & pubsubtopic tests

* adding test cases for wrong encoding 7 no encoding of pubsub topic

* adding test case test_time_filter_start_time_after_end_time

* adding more time tests

* adding tests with wrong start & end time

* adding invalid ascending test

* adding page_size tests

* adding invalid ascending test

* fix minor issues and adding comments

* fixing review comments

* minor change in test name

* Adding review comments
2024-10-24 13:16:37 +03:00

67 lines
3.2 KiB
Python

import pytest
from src.libs.common import to_base64
from src.steps.store import StepsStore
from src.libs.custom_logger import get_custom_logger
logger = get_custom_logger(__name__)
@pytest.mark.usefixtures("node_setup")
class TestPageSize(StepsStore):
def test_default_page_size(self):
for i in range(30):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
store_response = self.get_messages_from_store(node)
assert len(store_response.messages) == 20, "Message count mismatch"
def test_page_size_0_defaults_to_20(self):
for i in range(30):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=0)
assert len(store_response.messages) == 20, "Message count mismatch"
def test_max_page_size(self):
for i in range(200):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=200)
assert len(store_response.messages) == 100, "Message count mismatch"
@pytest.mark.parametrize("page_size", [1, 11, 39, 81, 99])
def test_different_page_size(self, page_size):
for i in range(page_size + 1):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=page_size)
assert len(store_response.messages) == page_size, "Message count mismatch"
def test_extreme_number_page_size(self):
for i in range(150):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=1000000)
assert len(store_response.messages) == 100, "Message count mismatch"
def test_negative_number_page_size(self):
page_size = -1
for i in range(10):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
logger.debug(f"requesting stored message with wrong page_size = {page_size}")
for node in self.store_nodes:
store_response = self.get_messages_from_store(node, page_size=page_size)
assert len(store_response.messages) == 10, "Message count mismatch"
def test_invalid_page_size(self):
page_size = "$2"
for i in range(10):
self.publish_message(message=self.create_message(payload=to_base64(f"Message_{i}")))
for node in self.store_nodes:
try:
store_response = self.get_messages_from_store(node, page_size=page_size)
raise Exception(f"invalid page number {page_size} was acepted !!")
except Exception as e:
logger.debug(f"the invalid page_size {page_size} wasn't accepted ")
assert e.args[0].find("400 Client Error: Bad Request for url"), "Error logged isn't for bad url"