-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use jiter for httpx responses; remove twice deserialization on XrpcError
- Loading branch information
Showing
6 changed files
with
58 additions
and
16 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
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
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,36 @@ | ||
import pytest | ||
from atproto_client.models.utils import is_json, load_json | ||
|
||
|
||
def test_load_json() -> None: | ||
assert load_json('{"key": "value"}') | ||
assert load_json(b'{"key": "value"}') | ||
|
||
assert load_json('{"key": "value"', strict=False) is None | ||
with pytest.raises(ValueError): | ||
load_json(b'{"key": "value"') | ||
|
||
assert load_json('{"key": "value"', strict=False) is None | ||
with pytest.raises(ValueError): | ||
load_json(b'{"key": "value"') | ||
|
||
assert load_json('{"key": "value"}'.encode('UTF-16'), strict=False) is None | ||
|
||
with pytest.raises(TypeError): | ||
load_json(None) | ||
|
||
|
||
def test_is_json() -> None: | ||
assert is_json('{"key": "value"}') is True | ||
assert is_json(b'{"key": "value"}') is True | ||
|
||
assert is_json('{"key": "value"') is False | ||
assert is_json(b'{"key": "value"') is False | ||
|
||
assert is_json('{"key": "value"}'.encode('UTF-16')) is False | ||
|
||
assert is_json(b'') is False | ||
assert is_json(b'{}') is True | ||
|
||
with pytest.raises(TypeError): | ||
load_json(None) |
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