Beispiel #1
0
def test_validates():
    assert (props.Datetime().load(datetime.datetime.fromisoformat(
        "1970-01-01")).isoformat() == "1970-01-01T00:00:00+00:00")
Beispiel #2
0
def test_wrong_type():
    with pytest.raises(props.PropertyValidationError):
        props.Datetime().load(12345)
Beispiel #3
0
def test_default():
    assert props.Datetime(default="1970-01-01").load(None).isoformat()
Beispiel #4
0
def test_not_nullable():
    with pytest.raises(props.PropertyValidationError):
        props.Datetime().load(None)
Beispiel #5
0
def test_nullable():
    props.Datetime(nullable=True).load(None)
Beispiel #6
0
def test_allow_strings_is_false():
    with pytest.raises(props.PropertyValidationError):
        props.Datetime(allow_strings=False).load("1970-01-01")
Beispiel #7
0
def test_from_invalid_string():
    with pytest.raises(props.PropertyValidationError):
        props.Datetime().load("nope")
Beispiel #8
0
def test_from_string_with_z():
    assert (props.Datetime().load("1970-01-01T00:00:00.000Z").isoformat() ==
            "1970-01-01T00:00:00+00:00")