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