コード例 #1
0
ファイル: tests.py プロジェクト: dipapaspyros/persona-builder
    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
ファイル: tests.py プロジェクト: dipapaspyros/persona-builder
    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
ファイル: tests.py プロジェクト: dipapaspyros/persona-builder
    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)