Skip to content

Commit

Permalink
fix: stream retry test
Browse files Browse the repository at this point in the history
  • Loading branch information
pnwpedro committed Oct 10, 2024
1 parent 1ee1633 commit c888a53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion fauna/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ def stream(
if opts.cursor is not None:
raise ClientError(
"The 'cursor' configuration can only be used with a stream token.")

token = self.query(fql).data
else:
token = fql
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/test_stream.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import threading
import time

import httpx
import pytest

from fauna import fql
from fauna.client import Client, StreamOptions
from fauna.errors import ClientError, NetworkError, RetryableFaunaException, QueryRuntimeError
from fauna.errors import ClientError, RetryableFaunaException, QueryRuntimeError, NetworkError
from fauna.http.httpx_client import HTTPXClient


Expand Down Expand Up @@ -107,11 +106,16 @@ def test_max_retries(scoped_secret):

count = [0]

def stream_func(*args, **kwargs):
old_send = httpx_client.send

def send_func(*args, **kwargs):
if not kwargs['stream']:
return old_send(*args, **kwargs)

count[0] += 1
raise NetworkError('foo')

httpx_client.stream = stream_func
httpx_client.send = send_func

count[0] = 0
with pytest.raises(RetryableFaunaException):
Expand Down

0 comments on commit c888a53

Please sign in to comment.