Beispiel #1
0
  def test_filter(self):
    class M(ModelBase):
      attrs = dict(first_name=None, last_name=None)

    m1 = M(first_name="trey", last_name=None)
    m2 = M(first_name=None, last_name=None)
    v = Validation.is_present("last_name").add_filter(lambda m: m.first_name is not None)

    self.assertFalse(v.validate(m1))
    self.assertTrue(v.validate(m2))
Beispiel #2
0
 def test_is_present(self):
   v = Validation.is_present("first_name")
   self.assertTrue(v.is_valid(self.model)[0])
   self.model.first_name = None
   self.assertFalse(v.is_valid(self.model)[0])