-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33aa28d
commit 0e2c55f
Showing
4 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pytest | ||
import asyncio | ||
from upstash_qstash.asyncio import Client | ||
from qstash_token import QSTASH_TOKEN | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
return Client(QSTASH_TOKEN) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_dlq(client): | ||
print("Publishing to a failed endpoint") | ||
pub_res = await client.publish_json({"url": "http://httpstat.us/404", "retries": 0}) | ||
|
||
msg_id = pub_res["messageId"] | ||
assert msg_id is not None | ||
|
||
print("Waiting 3 seconds for event to be delivered") | ||
await asyncio.sleep(3) | ||
|
||
print("Checking if message is in DLQ") | ||
dlq = client.dlq() | ||
all_messages_res = await dlq.list_messages() | ||
all_messages = all_messages_res["messages"] | ||
|
||
msg_sent = list(filter(lambda msg: msg["messageId"] == msg_id, all_messages)) | ||
assert len(msg_sent) == 1 | ||
|
||
dlq_id = msg_sent[0]["dlqId"] | ||
|
||
print("Deleting message from DLQ") | ||
await dlq.delete(dlq_id) | ||
|
||
print("Checking if message is deleted from DLQ") | ||
all_messages_after_delete_res = await dlq.list_messages() | ||
all_messages_after_delete = all_messages_after_delete_res["messages"] | ||
msg_deleted = list( | ||
filter(lambda msg: msg["messageId"] == msg_id, all_messages_after_delete) | ||
) | ||
assert len(msg_deleted) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import time | ||
from upstash_qstash import Client | ||
from qstash_token import QSTASH_TOKEN | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
return Client(QSTASH_TOKEN) | ||
|
||
|
||
def test_dlq(client): | ||
print("Publishing to a failed endpoint") | ||
pub_res = client.publish_json({"url": "http://httpstat.us/404", "retries": 0}) | ||
|
||
msg_id = pub_res["messageId"] | ||
assert msg_id is not None | ||
|
||
print("Waiting 3 seconds for event to be delivered") | ||
time.sleep(3) | ||
|
||
print("Checking if message is in DLQ") | ||
dlq = client.dlq() | ||
all_messages = dlq.list_messages()["messages"] | ||
|
||
msg_sent = list(filter(lambda msg: msg["messageId"] == msg_id, all_messages)) | ||
assert len(msg_sent) == 1 | ||
|
||
dlq_id = msg_sent[0]["dlqId"] | ||
|
||
print("Deleting message from DLQ") | ||
dlq.delete(dlq_id) | ||
|
||
print("Checking if message is deleted from DLQ") | ||
all_messages_after_delete = dlq.list_messages()["messages"] | ||
msg_deleted = list( | ||
filter(lambda msg: msg["messageId"] == msg_id, all_messages_after_delete) | ||
) | ||
assert len(msg_deleted) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters