Beispiel #1
0
def test_datetime_invalid():
    """A string is not a valid datetime"""

    test_datetime = DateTime()

    with assert_raises(InvalidPropertyError) as cm:
        test_datetime.validate('not a datetime')

    assert cm.exception.error == 'invalid'
Beispiel #2
0
def test_datetime_invalid():
    """A string is not a valid datetime"""

    test_datetime = DateTime()

    with assert_raises(InvalidPropertyError) as cm:
        test_datetime.validate('not a datetime')

    assert cm.exception.error == 'invalid'
Beispiel #3
0
def test_datetime_valid_1():
    """Should be ok (without microseconds)"""

    last_order_property = DateTime(include_microseconds=False)
    last_order_property.validate(datetime.now())

    class Bar(Model):
        last_order = last_order_property

    now = datetime.now().replace(microsecond=123456)
    some_bar = Bar(last_order=now)

    assert some_bar.last_order.microsecond == 0
Beispiel #4
0
def test_datetime_valid_1():
    """Should be ok (without microseconds)"""

    last_order_property = DateTime(include_microseconds=False)
    last_order_property.validate(datetime.now())

    class Bar(Model):
        last_order = last_order_property

    now = datetime.now().replace(microsecond=123456)
    some_bar = Bar(last_order=now)

    assert some_bar.last_order.microsecond == 0