コード例 #1
0
ファイル: test-trac-0094.py プロジェクト: Manexware/pyxb
 def testContainerAssignment (self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     self.assertTrue(isinstance(instance.anything, xs.int))
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0], pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>something</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
     instance.anything = 43
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0], pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>43</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
コード例 #2
0
ファイル: test-trac-0094.py プロジェクト: gothub/pyxb-d1
 def testContainerAssignment(self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     self.assertTrue(isinstance(instance.anything, xs.int))
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0],
                                pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>something</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
     instance.anything = 43
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0],
                                pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>43</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
コード例 #3
0
ファイル: check-validation.py プロジェクト: balanced/PyXB
 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())
コード例 #4
0
ファイル: test-trac-0037.py プロジェクト: pabigot/pyxb
 def testElement (self):
     i = union(4)
     self.assertTrue(i.validateBinding())
     i = union('two')
     self.assertTrue(i.validateBinding())
     i = xs.int(53.42)
     i = union(52.43)
     i = listUnion([1, 3, 'one', 'two', 2])
     self.assertTrue(i.validateBinding())
コード例 #5
0
ファイル: check-validation.py プロジェクト: Manexware/pyxb
 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())
コード例 #6
0
ファイル: test-trac-0037.py プロジェクト: gothub/pyxb-d1
 def testElement(self):
     i = union(4)
     self.assertTrue(i.validateBinding())
     i = union('two')
     self.assertTrue(i.validateBinding())
     i = xs.int(53.42)
     i = union(52.43)
     i = listUnion([1, 3, 'one', 'two', 2])
     self.assertTrue(i.validateBinding())
コード例 #7
0
ファイル: check-validation.py プロジェクト: Manexware/pyxb
 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())
コード例 #8
0
ファイル: test-200907231705.py プロジェクト: balanced/PyXB
 def testCtorMixed (self):
     instance = Mixed()
     self.assertRaises(pyxb.AttributeValidationError, instance.validateBinding)
     instance = Mixed(units='m')
     self.assertTrue(instance.validateBinding())
     instance = Mixed(4, units='m')
     self.assertTrue(instance.validateBinding())
     self.assertEqual(u'4', instance.orderedContent()[0].value)
     instance = Mixed(xs.int(4), units='m')
     self.assertTrue(instance.validateBinding())
     self.assertEqual(u'4', instance.orderedContent()[0].value)
コード例 #9
0
ファイル: check-validation.py プロジェクト: balanced/PyXB
 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())
コード例 #10
0
ファイル: test-trac-0094.py プロジェクト: balanced/PyXB
 def testContainerAssignment(self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     # You can do that, but you won't be able to convert it to xml
     self.assertRaises(AttributeError, instance.toxml)
     instance.anything = 43
     self.assertRaises(AttributeError, instance.toxml)
コード例 #11
0
ファイル: test-trac-0094.py プロジェクト: balanced/PyXB
 def testContainerAssignment (self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     # You can do that, but you won't be able to convert it to xml
     self.assertRaises(AttributeError, instance.toxml)
     instance.anything = 43
     self.assertRaises(AttributeError, instance.toxml)
コード例 #12
0
ファイル: check-validation.py プロジェクト: balanced/PyXB
 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)
コード例 #13
0
ファイル: check-validation.py プロジェクト: balanced/PyXB
 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)
コード例 #14
0
    def testMulti(self):
        instance = multi()
        self.assertRaises(pyxb.SimpleTypeValueError, SET_li, instance, 1)
        self.assertRaises(pyxb.SimpleTypeValueError, SET_li, instance,
                          [1, 2, 3])
        instance.li = [[1, 2, 3], [2, 3, 4]]
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance = multi([1, 2, 3], [1, 2, 3])  # two li values
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.orderedContent()))

        # The individual lists here aren't recognized as li elements, so this becomes something unknown
        self.assertRaises(pyxb.MixedContentError, multi,
                          [[1, 2, 3], [2, 3, 4]])

        self.assertRaises(pyxb.SimpleTypeValueError, multi, li=[1, 2, 3])

        instance = multi(li=[[1, 2, 3], [2, 3, 4]])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance = multi(li=[])
        instance.li.append(xs.int(1))
        self.assertRaises(pyxb.SimpleTypeValueError, instance.validateBinding)

        instance = CreateFromDocument('<multi><li>1</li></multi>')
        self.assertEqual(1, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance.li = []
        instance.li.append([1, 2, 3])
        instance.li.append([2, 3, 4])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.orderedContent()))
コード例 #15
0
ファイル: test-trac-0032.py プロジェクト: pabigot/pyxb
    def testMulti (self):
        instance = multi()
        self.assertRaises(pyxb.SimpleTypeValueError, SET_li, instance, 1)
        self.assertRaises(pyxb.SimpleTypeValueError, SET_li, instance, [1, 2, 3])
        instance.li = [[1,2,3], [2,3,4]]
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance = multi([1,2,3], [1,2,3]) # two li values
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.orderedContent()))

        # The individual lists here aren't recognized as li elements, so this becomes something unknown
        self.assertRaises(pyxb.MixedContentError, multi, [[1,2,3], [2,3,4]])

        self.assertRaises(pyxb.SimpleTypeValueError, multi, li=[1,2,3])

        instance = multi(li=[[1,2,3],[2,3,4]])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance = multi(li=[])
        instance.li.append(xs.int(1))
        self.assertRaises(pyxb.SimpleTypeValueError, instance.validateBinding)

        instance = CreateFromDocument('<multi><li>1</li></multi>')
        self.assertEqual(1, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.orderedContent()))

        instance.li = []
        instance.li.append([1,2,3])
        instance.li.append([2,3,4])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.orderedContent()))
コード例 #16
0
ファイル: test-trac-0032.py プロジェクト: thorstenb/pyxb
    def testMulti (self):
        instance = multi()
        self.assertRaises(pyxb.BadTypeValueError, SET_li, instance, 1)
        self.assertRaises(pyxb.BadTypeValueError, SET_li, instance, [1, 2, 3])
        instance.li = [[1,2,3], [2,3,4]]
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.content()))

        instance = multi([1,2,3], [1,2,3]) # two li values
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.content()))

        self.assertRaises(pyxb.UnrecognizedContentError, multi, [[1,2,3], [2,3,4]])
        self.assertRaises(pyxb.BadTypeValueError, multi, li=[1,2,3])

        instance = multi(li=[[1,2,3],[2,3,4]])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.content()))

        instance = multi(li=[])
        instance.li.append(xs.int(1))
        self.assertRaises(pyxb.BindingValidationError, instance.validateBinding)

        instance = CreateFromDocument('<multi><li>1</li></multi>')
        self.assertEqual(1, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(1, len(instance.content()))
        
        instance.li = []
        instance.li.append([1,2,3])
        instance.li.append([2,3,4])
        self.assertEqual(2, len(instance.li))
        self.assertTrue(instance.validateBinding())
        self.assertEqual(2, len(instance.content()))
コード例 #17
0
ファイル: test-issue-0071.py プロジェクト: pabigot/pyxb
 def testInt (self):
     self.assertEqual(0, xs.int());
     self.assertEqual(0, CreateFromDocument(six.u('<int>0</int>')));
     self.assertRaises(SimpleTypeValueError, CreateFromDocument, six.u('<int/>'));
コード例 #18
0
 def testInt(self):
     self.assertEqual(0, xs.int())
     self.assertEqual(0, CreateFromDocument(six.u('<int>0</int>')))
     self.assertRaises(SimpleTypeValueError, CreateFromDocument,
                       six.u('<int/>'))