def test_form(self):

    # first create a new entity
    f = TestModelForm()
    params = {"number": "12", "data_field": "data string",
              "is_active": "False", "string_list_field": "list"}
    self.assertEqual(f.validate(params), True)
    f.save()
    self.assertEqual(TestModel.all().count(), 1)
    entity = TestModel.all().get()
    self.assertEqual(entity.number, 12)

    # modify with TestModelForm
    f = TestModelForm(instance=entity)
    params = {"number": "13", "data_field": "modified data",
              "is_active": "True", "string_list_field": "line 1\nline 2"}
    self.assertEqual(f.validate(params), True)
    f.save()

    # check values
    self.assertEqual(TestModel.all().count(), 1)
    entity = TestModel.all().get()
    self.assertEqual(entity.number, 13)
    self.assertEqual(entity.data_field, "modified data")
    self.assertEqual(entity.is_active, True)
    self.assertEqual(entity.string_list_field, ["line 1", "line 2"])

    """Form validation test with ModelForm."""
    os.environ['REQUEST_METHOD'] = 'POST'
    local.request = Request(get_env())
    f = TestModelForm()
    params = {"number": "12"}
    # In your view, you can validate the form data with:
    # f.validate(request.form)
    # or with(If you have FileField):
    # f.validate(request.form, request.files)
    self.assertEqual(f.validate(params), False)
    f.reset()
    params = {"number": "12",
              "data_field": "data string longer than 20 characters",
              "is_active": "False",
              "string_list_field": "test"}
    self.assertEqual(f.validate(params), False)

    f.reset()
    params = {"number": "12",
              "data_field": "data string",
              "is_active": "False",
              "string_list_field": ""}
    self.assertEqual(f.validate(params), False)

    # create a new entity
    f.reset()
    params = {"number": "12", "data_field": "data string",
              "is_active": "False", "string_list_field": "list"}
    self.assertEqual(f.validate(params), True)
    f.save()
    self.assertEqual(TestModel.all().count(), 2)
Check neutron segmentation ids
dataset/ETHPy150Open IanLewis/kay/kay/tests/formtest.py/ModelFormTest.test_form--crossover with--dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/extensions/network_manager/checker.py/NetworkCheck.neutron_check_segmentation_ids