-
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
80b7d87
commit 88eba62
Showing
2 changed files
with
49 additions
and
1 deletion.
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,49 @@ | ||
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_schedule_lifecycle(client): | ||
sched = client.schedules() | ||
create_res = await sched.create( | ||
{ | ||
"cron": "* * * * *", | ||
"destination": "https://example.com", | ||
"body": {"ex_key": "ex_value"}, | ||
"headers": { | ||
"content-type": "application/json", | ||
}, | ||
} | ||
) | ||
|
||
sched_id = create_res["scheduleId"] | ||
assert sched_id is not None | ||
|
||
print("Waiting 1 seconds for schedule to be delivered") | ||
await asyncio.sleep(1) | ||
|
||
print("Checking if schedule is delivered") | ||
get_res = await sched.get(sched_id) | ||
assert get_res["scheduleId"] == sched_id | ||
assert get_res["cron"] == "* * * * *" | ||
|
||
print("Checking if schedule is in list") | ||
list_res = await sched.list() | ||
assert any(s["scheduleId"] == sched_id for s in list_res) | ||
|
||
print("Deleting schedule") | ||
await sched.delete(sched_id) | ||
|
||
print("Waiting 1 second for schedule to be deleted") | ||
await asyncio.sleep(1) | ||
|
||
print("Checking if schedule is deleted") | ||
list_res = await sched.list() | ||
assert not any(s["scheduleId"] == sched_id for s in list_res) |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import pytest | ||
import dotenv | ||
import time | ||
from upstash_qstash import Client | ||
from qstash_token import QSTASH_TOKEN | ||
|