Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test for test_subscribe_push_bound #633

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
============================= test session starts ==============================
platform darwin -- Python 3.11.6, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/shang-kuanl/Downloads/nats_hackathon2024/nats.py
configfile: pyproject.toml
plugins: anyio-4.3.0
collected 0 items

============================ no tests ran in 0.00s =============================
30 changes: 20 additions & 10 deletions tests/test_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import uuid
from hashlib import sha256

# test: dir
import os

import nats
import nats.js.api
import pytest
Expand Down Expand Up @@ -1611,12 +1614,17 @@ async def cb2(msg):

# Create a sync subscriber now.
sub2 = await js.subscribe("pbound", durable="two")
msg = await sub2.next_msg()
assert msg.data == b"Hello World 0"
assert msg.metadata.sequence.stream == 1
assert msg.metadata.sequence.consumer == 1
assert sub2.pending_msgs == 9

for i in range(10):
msg = await sub2.next_msg()
assert msg.data == f'Hello World {i}'.encode()
assert msg.metadata.sequence.stream == i+1
assert msg.metadata.sequence.consumer == i+1

# print the warning that the coroutine was never awaited.
warn_msg = "coroutine 'JetStreamContext.PushSubscription.next_msg' was never awaited"
with pytest.warns(RuntimeWarning, match=warn_msg):
sub2.next_msg()

await nc.close()

@async_test
Expand Down Expand Up @@ -2614,8 +2622,8 @@ async def error_handler(e):
# Check remaining messages in the stream state.
status = await kv.status()
# NOTE: Behavior changed here from v2.10.9 => v2.10.10
# assert status.values == 2
assert status.values == 1
assert status.values == 2
# assert status.values == 1

entry = await kv.get("hello")
assert "hello" == entry.key
Expand All @@ -2630,13 +2638,13 @@ async def error_handler(e):
assert 1 == entry.revision

status = await kv.status()
assert status.values == 1
assert status.values == 2

for i in range(100, 200):
await kv.put(f"hello.{i}", b"Hello JS KV!")

status = await kv.status()
assert status.values == 101
assert status.values == 102

with pytest.raises(NotFoundError):
await kv.get("hello.5")
Expand Down Expand Up @@ -3610,6 +3618,7 @@ async def error_handler(e):

@async_test
async def test_object_big_files(self):
print('hello???')
errors = []

async def error_handler(e):
Expand Down Expand Up @@ -3657,6 +3666,7 @@ async def error_handler(e):
assert info.digest == "SHA-256=mhT1pLyi9JlIaqwVmvt0wQp2x09kor_80Lirl4SDblA="

# Using a local file.
print('Current working directory:', os.getcwd(), flush=True)
with open("pyproject.toml") as f:
info = await obs.put("pyproject", f.buffer)
assert info.name == "pyproject"
Expand Down
Loading