def test_matches_named_scalar(self): p = Property(self.um, '^Ranges.from_float_value(10..20=L|20..30=M|30..40=H, 35)', None, tp='###') self.assertTrue(p.matches('L', '=L')) self.assertFalse(p.matches('L', '<L')) self.assertTrue(p.matches('H', '>L')) self.assertTrue(p.matches('M', '!=L'))
def test_matches_string(self): p = Property(self.um, '^Person.first_name', None) self.assertTrue(p.matches('Nick', '=Nick')) self.assertFalse(p.matches('Nick', '=John')) self.assertFalse(p.matches('Nick', '!=Nick')) self.assertTrue(p.matches('Nick', '!=John')) # test quoted self.assertTrue(p.matches('Nick', '="Nick"'))
def test_matches_scalar(self): p = Property(self.um, '^Ranges.from_float_value(10..20|20..30|30..40, 35)', None, tp='###') self.assertTrue(p.matches('10..20', '=10..20')) self.assertFalse(p.matches('10..20', '<10..20')) self.assertTrue(p.matches('20..30', '>10..20')) self.assertTrue(p.matches('20..30', '!=10..20')) # test wrong ranges with self.assertRaises(ValueError): self.assertTrue(p.matches('20..29', '>10..20')) with self.assertRaises(ValueError): self.assertTrue(p.matches('20..30', '!=10..15'))
def test_matches_named_scalar(self): p = Property( self.um, '^Ranges.from_float_value(10..20=L|20..30=M|30..40=H, 35)', None, tp='###') self.assertTrue(p.matches('L', '=L')) self.assertFalse(p.matches('L', '<L')) self.assertTrue(p.matches('H', '>L')) self.assertTrue(p.matches('M', '!=L'))
def test_exception_on_missing_type_helper(self): with self.assertRaises(ProviderMethodNotFound): Property(self.um, '^Person.first_name', None, tp='###')
def test_dynamic_type_with_helper(self): p = Property(self.um, '^Ranges.from_float_value(10..20|20..30|30..40, 35)', None, tp='###') self.assertEqual(p.tp, 'Scalar(10..20,20..30,30..40)')
def test_exception_on_wrong_provider_method(self): with self.assertRaises(ProviderMethodNotFound): Property(self.um, '^Person.first_name_wrong', None)
def test_exception_on_wrong_provider(self): with self.assertRaises(ProviderNotFound): Property(self.um, '^Person_wrong.first_name', None)
def test_load_existing_provider(self): Property(self.um, '^Person.first_name', None)