Exemple #1
0
def test_model_as_dict():
    """ Model.as_dict() should only include field attributes and reflect their
        current value"""
    m = Model(a=11)
    m.id = 12
    m.b = 13
    eq_({'id': 12, 'cls': 'Model'}, m.as_dict())
Exemple #2
0
def test_model_del_field():
    """ Deleting a model object's field attribute should behave like deleting
        a regular attribute without affecting the class or sister objects """
    m = Model()
    del m.cls

    assert_raises(AttributeError, getattr, m, 'cls')
    ok_('cls' not in m.as_dict())

    ok_(Model.cls)
    eq_('Model', Model().cls)