'Test Model add validations'

def test_model_add_validation(self):

    client = self.app.test_client()
    self.login(client, DEFAULT_ADMIN_USER, DEFAULT_ADMIN_PASSWORD)
    rv = client.post('/model1view/add', data=dict(field_string='test1', field_integer='1'), follow_redirects=True)
    eq_(rv.status_code, 200)
    rv = client.post('/model1view/add', data=dict(field_string='test1', field_integer='2'), follow_redirects=True)
    eq_(rv.status_code, 200)
    data = rv.data.decode('utf-8')
    ok_((UNIQUE_VALIDATION_STRING in data))
    model = self.db.session.query(Model1).all()
    eq_(len(model), 1)
    rv = client.post('/model1view/add', data=dict(field_string='', field_integer='1'), follow_redirects=True)
    eq_(rv.status_code, 200)
    data = rv.data.decode('utf-8')
    ok_((NOTNULL_VALIDATION_STRING in data))
    model = self.db.session.query(Model1).all()
    eq_(len(model), 1)
