Ejemplo n.º 1
0
    def test_assign_value_strict(self):
        cmp_str = 'xxx'
        c = SubComponent('CWE_1', validation_level=VALIDATION_LEVEL.STRICT)
        c.value = cmp_str
        parsed_cmp = parse_component(cmp_str, 'CWE_1')
        self.assertEqual(c.to_er7(), parsed_cmp.to_er7())

        with self.assertRaises(MaxLengthReached):
            for dt in ('ST', 'ID', 'FT', 'GTS', 'IS', 'TX'):
                c = SubComponent(datatype=dt, validation_level=VALIDATION_LEVEL.STRICT) # max length reached string type
                c.value = 65537*'a'
            for dt in ('NM', 'SI'):
                c = SubComponent(datatype=dt, validation_level=VALIDATION_LEVEL.STRICT)
                c.value = int(65537*'1')
Ejemplo n.º 2
0
    def test_assign_value_quiet(self):
        cmp_str = 'xxx'
        c = SubComponent('CWE_1')
        c.value = cmp_str
        parsed_cmp = parse_component(cmp_str, 'CWE_1')
        self.assertEqual(c.to_er7(), parsed_cmp.to_er7())

        c = SubComponent('CWE_1') # more child than allowed
        c.value = '1&2'
        for dt in ('ST', 'ID', 'FT', 'GTS', 'IS', 'TX'):
            c = SubComponent(datatype=dt) # max length reached string type
            c.value = 65537*'a'
        for dt in ('NM', 'SI'):
            c = SubComponent(datatype=dt)
            c.value = 65537*'1'