'Test Model add, delete, edit for Model with Enum Columns'

def test_model_crud_with_enum(self):

    client = self.app.test_client()
    rv = self.login(client, DEFAULT_ADMIN_USER, DEFAULT_ADMIN_PASSWORD)
    data = {'enum1': u'e1'}
    if _has_enum:
        data['enum2'] = 'e1'
    rv = client.post('/modelwithenumsview/add', data=data, follow_redirects=True)
    eq_(rv.status_code, 200)
    model = self.db.session.query(ModelWithEnums).first()
    eq_(model.enum1, u'e1')
    if _has_enum:
        eq_(model.enum2, TestEnum.e1)
    data = {'enum1': u'e2'}
    if _has_enum:
        data['enum2'] = 'e2'
    rv = client.post('/modelwithenumsview/edit/1', data=data, follow_redirects=True)
    eq_(rv.status_code, 200)
    model = self.db.session.query(ModelWithEnums).first()
    eq_(model.enum1, u'e2')
    if _has_enum:
        eq_(model.enum2, TestEnum.e2)
    rv = client.get('/modelwithenumsview/delete/1', follow_redirects=True)
    eq_(rv.status_code, 200)
    model = self.db.session.query(ModelWithEnums).first()
    eq_(model, None)
