|
|
@ -1,6 +1,11 @@ |
|
|
|
import json |
|
|
|
|
|
|
|
import bsonjs |
|
|
|
# Because of python 3.8 doesn't support this library |
|
|
|
try: |
|
|
|
import bsonjs # type: ignore |
|
|
|
except ImportError: # pragma: nocover |
|
|
|
bsonjs = None |
|
|
|
|
|
|
|
from fastapi import FastAPI |
|
|
|
from fastapi.responses import BSONJSResponse |
|
|
|
from fastapi.testclient import TestClient |
|
|
@ -20,4 +25,9 @@ def test_bsonjs_serialized_data(): |
|
|
|
with client: |
|
|
|
response = client.get("/bsonjs_keys") |
|
|
|
|
|
|
|
assert response.content == bsonjs.loads(json.dumps({"key": "Hello World", 1: 1})) |
|
|
|
if bsonjs is not None: |
|
|
|
assert response.content == bsonjs.loads( |
|
|
|
json.dumps({"key": "Hello World", 1: 1}) |
|
|
|
) |
|
|
|
|
|
|
|
assert True |
|
|
|