Exemple #1
0
    def testSchemaSupport (self):
        cym1 = trac26.eConcCardCymru('un')
        eng3 = trac26.eConcCardEnglish('three')

        # Incremental through owning element
        instance = trac26.eCardinals()
        self.assertEqual(0, len(instance.eAbstractCard))
        instance.append(cym1)
        self.assertEqual(1, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        instance.append(eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Incremental through construtor element
        instance = trac26.eCardinals(cym1, eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Through parsing
        instance = trac26.CreateFromDocument(self.Good_xmlt)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
Exemple #2
0
 def testSchemaSupport(self):
     instance = trac26.eTranslateCardMulti(trac26.eConcCardCymru('un'),
                                           trac26.eConcCardEnglish('one'),
                                           xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance.eConcCardCymru.append('dau')
     instance.eConcCardEnglish.append('two')
     instance.cardinal.append(2)
     self.assertTrue(instance.validateBinding())
Exemple #3
0
 def testSchemaSupport (self):
     instance = trac26.eTranslateCardMulti(trac26.eConcCardCymru('un'),
                                           trac26.eConcCardEnglish('one'),
                                           xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance.eConcCardCymru.append('dau')
     instance.eConcCardEnglish.append('two')
     instance.cardinal.append(2)
     self.assertTrue(instance.validateBinding())
Exemple #4
0
 def testSchemaSupport (self):
     instance = trac26.eTranslateCard(trac26.eConcCardCymru('un'),
                                      trac26.eConcCardEnglish('one'),
                                      xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance = trac26.CreateFromDocument(self.Good_xmlt)
     self.assertEqual(self.Good_xmld, instance.toxml('utf-8', root_only=True))
     instance = trac26.eTranslateCard(trac26.eConcCardCymru('un'))
     instance.cardinal = 1
     instance.eConcCardEnglish = 'one'
     self.assertTrue(instance.validateBinding())
Exemple #5
0
 def testSchemaSupport(self):
     instance = trac26.eTranslateCard(trac26.eConcCardCymru('un'),
                                      trac26.eConcCardEnglish('one'),
                                      xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance = trac26.CreateFromDocument(self.Good_xmlt)
     self.assertEqual(self.Good_xmld, instance.toxml('utf-8',
                                                     root_only=True))
     instance = trac26.eTranslateCard(trac26.eConcCardCymru('un'))
     instance.cardinal = 1
     instance.eConcCardEnglish = 'one'
     self.assertTrue(instance.validateBinding())
Exemple #6
0
 def testException(self):
     instance = trac26.eTranslateCardMulti(trac26.eConcCardCymru('un'),
                                           trac26.eConcCardEnglish('one'),
                                           xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance.cardinal.append(2)
     with self.assertRaises(pyxb.UnprocessedElementContentError) as cm:
         instance.validateBinding()
     e = cm.exception
     self.assertTrue(e.fac_configuration.isAccepting())
     self.assertEqual(3, len(e.symbols))
     self.assertEqual(1, len(e.symbol_set))
     (ed, syms) = e.symbol_set.iteritems().next()
     self.assertEqual(1, len(syms))
     self.assertEqual(instance.cardinal[1], syms[0])
     self.assertEqual(e.details(), self.Bad_details)
Exemple #7
0
 def testException (self):
     instance = trac26.eTranslateCardMulti(trac26.eConcCardCymru('un'),
                                           trac26.eConcCardEnglish('one'),
                                           xs.int(1))
     self.assertTrue(instance.validateBinding())
     instance.cardinal.append(2)
     with self.assertRaises(pyxb.UnprocessedElementContentError) as cm:
         instance.validateBinding()
     e = cm.exception
     self.assertTrue(e.fac_configuration.isAccepting())
     self.assertEqual(3, len(e.symbols))
     self.assertEqual(1, len(e.symbol_set))
     (ed, syms) = e.symbol_set.iteritems().next()
     self.assertEqual(1, len(syms))
     self.assertEqual(instance.cardinal[1], syms[0])
     self.assertEqual(e.details(), self.Bad_details)
Exemple #8
0
    def testSchemaSupport(self):
        cym1 = trac26.eConcCardCymru('un')
        eng3 = trac26.eConcCardEnglish('three')

        # Incremental through owning element
        instance = trac26.eCardinals()
        self.assertEqual(0, len(instance.eAbstractCard))
        instance.append(cym1)
        self.assertEqual(1, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        instance.append(eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Incremental through construtor element
        instance = trac26.eCardinals(cym1, eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Through parsing
        instance = trac26.CreateFromDocument(self.Good_xmlt)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())