Exemple #1
0
 def test_validate_value_partial(self):
     sd = SegmentDefinition(fields=(
         SegmentField(name='a'),
         SegmentField(name='b',
                      re_pattern='(?<=[0])|(?<![0])(?:0|[1-9][0-9]*)',
                      render=lambda x: "" if x is None else str(x))))
     self.assertEqual((0, None), sd.validate_value((0, None)))
     self.assertEqual((0, None), sd.validate_value((0, )))
     self.assertRaises(ValueError, sd.validate_value, (0, 3))
     self.assertEqual((1, 2), sd.validate_value((1, 2)))
     self.assertRaises(ValueError, sd.validate_value, (1, ))
Exemple #2
0
 def test_validate_value_partial(self):
     sd = SegmentDefinition(fields=(
         SegmentField(name='a'),
         SegmentField(name='b',
                      re_pattern='(?<=[0])|(?<![0])(?:0|[1-9][0-9]*)',
                      render=lambda x: "" if x is None else str(x))))
     self.assertEqual((0, None), sd.validate_value((0, None)))
     self.assertEqual((0, None), sd.validate_value((0,)))
     self.assertRaises(ValueError, sd.validate_value, (0, 3))
     self.assertEqual((1, 2), sd.validate_value((1, 2)))
     self.assertRaises(ValueError, sd.validate_value, (1,))
Exemple #3
0
 def test_validate_value(self):
     sd = SegmentDefinition(fields=(SegmentField(name='a'),
                                    SegmentField(name='b')))
     self.assertEqual((1, 2), sd.validate_value((1, 2)))
     self.assertEqual((4, 3), sd.validate_value([4, 3]))
Exemple #4
0
 def test_validate_value(self):
     sd = SegmentDefinition(fields=(SegmentField(name='a'),
                                    SegmentField(name='b')))
     self.assertEqual((1, 2), sd.validate_value((1, 2)))
     self.assertEqual((4, 3), sd.validate_value([4, 3]))