예제 #1
0
    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'))
예제 #2
0
    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"'))
예제 #3
0
    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'))
예제 #4
0
    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'))
예제 #5
0
    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'))
예제 #6
0
    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"'))
예제 #7
0
 def test_exception_on_missing_type_helper(self):
     with self.assertRaises(ProviderMethodNotFound):
         Property(self.um, '^Person.first_name', None, tp='###')
예제 #8
0
 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)')
예제 #9
0
 def test_exception_on_wrong_provider_method(self):
     with self.assertRaises(ProviderMethodNotFound):
         Property(self.um, '^Person.first_name_wrong', None)
예제 #10
0
 def test_exception_on_wrong_provider(self):
     with self.assertRaises(ProviderNotFound):
         Property(self.um, '^Person_wrong.first_name', None)
예제 #11
0
 def test_load_existing_provider(self):
     Property(self.um, '^Person.first_name', None)