2019-08-28 17:57:16 +02:00
|
|
|
from datetime import datetime as dt
|
2021-08-27 22:10:06 +02:00
|
|
|
from moulinette.interfaces import JSONExtendedEncoder
|
2019-08-28 17:57:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_json_extended_encoder(caplog):
|
|
|
|
encoder = JSONExtendedEncoder()
|
|
|
|
|
|
|
|
assert encoder.default(set([1, 2, 3])) == [1, 2, 3]
|
|
|
|
|
2019-11-25 17:21:13 +01:00
|
|
|
assert encoder.default(dt(1917, 3, 8)) == "1917-03-08T00:00:00+00:00"
|
2019-08-28 17:57:16 +02:00
|
|
|
|
2019-11-25 17:21:13 +01:00
|
|
|
assert encoder.default(None) == "None"
|
2019-08-28 17:57:16 +02:00
|
|
|
for message in caplog.messages:
|
2019-11-25 17:21:13 +01:00
|
|
|
assert "cannot properly encode in JSON" in message
|