Skip to content

Commit

Permalink
review comments for clearer test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
taddes committed Jan 30, 2024
1 parent a2746a7 commit f775454
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions tests/integration/test_integration_all_rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __getattribute__(self, name: str):
return f

def connect(self, connection_port: int | None = None):
"""Connect."""
"""Establish a websocket connection to localhost at the provided `connection_port`."""
url = self.url
if connection_port: # pragma: nocover
url = "ws://localhost:{}/".format(connection_port)
Expand Down Expand Up @@ -264,7 +264,7 @@ def hello(self, uaid: str | None = None, services: list[str] | None = None):
return result

def broadcast_subscribe(self, services: list[str]):
"""Broadcast subscribe."""
"""Broadcast WebSocket subscribe."""
if not self.ws:
raise Exception("WebSocket client not available as expected")

Expand Down Expand Up @@ -432,7 +432,7 @@ def ack(self, channel, version):
self.ws.send(msg)

def disconnect(self):
"""Disconnect"""
"""Disconnect from the application websocket."""
self.ws.close()

def sleep(self, duration: int): # pragma: nocover
Expand Down Expand Up @@ -480,7 +480,7 @@ def _get_vapid(


def enqueue_output(out, queue):
"""Enqueue output."""
"""Add lines from the out buffer to the provided queue."""
for line in iter(out.readline, b""):
queue.put(line)
out.close()
Expand Down Expand Up @@ -533,7 +533,7 @@ def max_logs(endpoint=None, conn=None):
"""

def max_logs_decorator(func):
"""Decorate max_logs."""
"""Overwrite `max_endpoint_logs` with a given endpoint if it is specified."""

def wrapper(self, *args, **kwargs):
if endpoint is not None:
Expand Down Expand Up @@ -567,7 +567,7 @@ class CustomClient(Client):
"""Custom Client for testing."""

def send_bad_data(self):
"""Set `bad-data`"""
"""Send an invalid data message via websocket to the autoconnect client."""
self.ws.send("bad-data")


Expand All @@ -584,7 +584,9 @@ def kill_process(process):


def get_rust_binary_path(binary):
"""Get Rust binary path."""
"""Get path to pre-built Rust binary.
This presumes that the application has already been built with proper features.
"""
global STRICT_LOG_COUNTS

rust_bin = root_dir + "/target/release/{}".format(binary)
Expand All @@ -604,7 +606,7 @@ def get_rust_binary_path(binary):


def write_config_to_env(config, prefix):
"""Write configurations to env."""
"""Write configurations to application read environment variables."""
for key, val in config.items():
new_key = prefix + key
log.debug("✍ config {} => {}".format(new_key, val))
Expand Down Expand Up @@ -953,7 +955,7 @@ def test_hello_echo(self):

@inlineCallbacks
def test_hello_with_bad_prior_uaid(self):
"""Test hello with bard prior uaid."""
"""Test hello with bad prior uaid."""
non_uaid = uuid.uuid4().hex
client = Client(self._ws_url)
yield client.connect()
Expand All @@ -965,7 +967,7 @@ def test_hello_with_bad_prior_uaid(self):

@inlineCallbacks
def test_basic_delivery(self):
"""Test basic delivery."""
"""Test basic regular push message delivery."""
data = str(uuid.uuid4())
client: Client = yield self.quick_register()
result = yield client.send_notification(data=data)
Expand All @@ -978,7 +980,7 @@ def test_basic_delivery(self):

@inlineCallbacks
def test_topic_basic_delivery(self):
"""Test topic basic delivery."""
"""Test basic topic push message delivery."""
data = str(uuid.uuid4())
client = yield self.quick_register()
result = yield client.send_notification(data=data, topic="Inbox")
Expand All @@ -991,7 +993,7 @@ def test_topic_basic_delivery(self):

@inlineCallbacks
def test_topic_replacement_delivery(self):
"""Test topic replacement delivery."""
"""Test that a topic push message replaces it's prior version."""
data = str(uuid.uuid4())
data2 = str(uuid.uuid4())
client = yield self.quick_register()
Expand Down Expand Up @@ -1040,7 +1042,7 @@ def test_topic_no_delivery_on_reconnect(self):

@inlineCallbacks
def test_basic_delivery_with_vapid(self):
"""Test basic delivery with vapid."""
"""Test delivery of a basic push message with a VAPID header."""
data = str(uuid.uuid4())
client = yield self.quick_register()
vapid_info = _get_vapid(payload=self.vapid_payload)
Expand All @@ -1054,7 +1056,7 @@ def test_basic_delivery_with_vapid(self):

@inlineCallbacks
def test_basic_delivery_with_invalid_vapid(self):
"""Test basic delivery with invalid vapid."""
"""Test basic delivery with invalid VAPID header."""
data = str(uuid.uuid4())
client = yield self.quick_register()
vapid_info = _get_vapid(payload=self.vapid_payload, endpoint=self.host_endpoint(client))
Expand All @@ -1064,7 +1066,7 @@ def test_basic_delivery_with_invalid_vapid(self):

@inlineCallbacks
def test_basic_delivery_with_invalid_vapid_exp(self):
"""Test basic delivery with invalid vapid exp."""
"""Test basic delivery of a push message with invalid VAPID `exp` assertion."""
data = str(uuid.uuid4())
client = yield self.quick_register()
vapid_info = _get_vapid(
Expand Down Expand Up @@ -1515,7 +1517,7 @@ def test_delete_saved_notification(self):

@inlineCallbacks
def test_with_key(self):
"""Test with key."""
"""Test getting a locked subscription with a valid VAPID public key."""
private_key = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
claims = {
"aud": "http://localhost:{}".format(ENDPOINT_PORT),
Expand Down

0 comments on commit f775454

Please sign in to comment.