def test_form(self):
    os.environ['REQUEST_METHOD'] = 'POST'
    local.request = Request(get_env())
    f = TestForm()
    f.model_field.set_query(TestModel2.all().filter('is_active =', True))
    params = {'username': 'hoge'}
    self.assertEqual(f.validate(params), False)
    params = {
      'username': 'hoge',
      'password': 'fugafuga',
      'password_again': 'fugafuga',
      'string_list_field': 'hoge',
      'model_field': str(TestModel2.all().filter('is_active =', True).get().key())
    }
    result = f.validate(params)
    self.assertEqual(result, True)

    params['password_again'] = 'moge'
    result = f.validate(params)
    self.assertEqual(result, False)
Form validation test with context_validate.
dataset/ETHPy150Open IanLewis/kay/kay/tests/formtest.py/FormTest.test_form