How to use the chaostoolkit.cli.encoder function in chaostoolkit

To help you get started, we’ve selected a few chaostoolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_failure():
    class Dummy:
        pass

    with pytest.raises(TypeError) as x:
        encoder(Dummy())
github chaostoolkit / chaostoolkit / tests / test_encoder.py View on Github external
def test_encode_decimal():
    d = decimal.Decimal("6.7")

    doc = json.dumps({"d": d}, default=encoder)
    assert str(d) in doc
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_decimal():
    d = Decimal('1.38')
    assert encoder(d) == '1.38'
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_datetime():
    now = datetime.utcnow()
    assert encoder(now) == now.isoformat()
github chaostoolkit / chaostoolkit / tests / test_cli.py View on Github external
def test_json_encoder_uuid():
    u = uuid.uuid4()
    assert encoder(u) == str(u)
github chaostoolkit / chaostoolkit / tests / test_encoder.py View on Github external
def test_encode_date_and_datetime():
    now = datetime.now()
    utcnow = datetime.utcnow()
    today = datetime.today()

    d = {"now": now, "utcnow": utcnow, "today": today}
    
    doc = json.dumps(d, default=encoder)

    assert now.isoformat() in doc
    assert utcnow.isoformat() in doc
    assert today.isoformat() in doc