|
1 | 1 | import datetime |
2 | | -import json |
3 | 2 |
|
4 | 3 | import pytest |
5 | 4 | import sqlalchemy as sa |
| 5 | +from crate.client.http import json_dumps |
6 | 6 |
|
7 | | -from cratedb_toolkit.util.sqlalchemy import CrateJsonEncoderWithNumPy |
8 | 7 | from tests.conftest import TESTDRIVE_DATA_SCHEMA |
9 | 8 |
|
10 | 9 |
|
@@ -48,18 +47,24 @@ def test_inspector_patched(database, needs_sqlalchemy2): |
48 | 47 | def test_json_encoder_date(): |
49 | 48 | """ |
50 | 49 | Verify the extended JSON encoder also accepts Python's `date` types. |
| 50 | +
|
| 51 | + TODO: Move to different test file, as this no longer requires |
| 52 | + monkeypatching after using orjson for marshalling. |
51 | 53 | """ |
52 | 54 | data = {"date": datetime.date(2024, 6, 4)} |
53 | | - encoded = json.dumps(data, cls=CrateJsonEncoderWithNumPy) |
54 | | - assert encoded == '{"date": 1717459200000}' |
| 55 | + encoded = json_dumps(data) |
| 56 | + assert encoded == b'{"date":"2024-06-04"}' |
55 | 57 |
|
56 | 58 |
|
57 | 59 | def test_json_encoder_numpy(): |
58 | 60 | """ |
59 | 61 | Verify the extended JSON encoder also accepts NumPy types. |
| 62 | +
|
| 63 | + TODO: Move to different test file, as this no longer requires |
| 64 | + monkeypatching after using orjson for marshalling. |
60 | 65 | """ |
61 | 66 | np = pytest.importorskip("numpy") |
62 | 67 |
|
63 | 68 | data = {"scalar-int": np.float32(42.42).astype(int), "scalar-float": np.float32(42.42), "ndarray": np.ndarray([1])} |
64 | | - encoded = json.dumps(data, cls=CrateJsonEncoderWithNumPy) |
65 | | - assert encoded == """{"scalar-int": 42, "scalar-float": 42.41999816894531, "ndarray": [2.08e-322]}""" |
| 69 | + encoded = json_dumps(data) |
| 70 | + assert encoded == b"""{"scalar-int":42,"scalar-float":42.42,"ndarray":[2.08e-322]}""" |
0 commit comments