コード例 #1
0
 def test_load(self):
     obj = factory.load('tests/exercise.xml')
     self.assertEqual(obj.tagname, 'Exercise')
     try:
         obj = factory.load('tests/exercise-notvalid.xml')
         assert 0
     except etree.DocumentInvalid, e:
         self.assertEqual(
             str(e),
             'Element comments content does not follow the DTD, expecting '
             '(comment)+, got (), line 17'
         )
コード例 #2
0
ファイル: test_factory.py プロジェクト: samjy/xmltool
 def test_load(self):
     obj = factory.load('tests/exercise.xml')
     self.assertEqual(obj._tagname, 'Exercise')
     try:
         obj = factory.load('tests/exercise-notvalid.xml')
         assert 0
     except etree.DocumentInvalid, e:
         self.assertEqual(
             str(e),
             'Element comments content does not follow the DTD, expecting '
             '(comment)+, got (), line 17'
         )
コード例 #3
0
ファイル: test_factory.py プロジェクト: LeResKP/xmltool
 def test_load(self):
     obj = factory.load('tests/exercise.xml')
     self.assertEqual(obj.tagname, 'Exercise')
     comment = obj['test'][1]['comments']['comment'][1]
     self.assertEqual(comment.text, '<div>My comment 2</div>')
     self.assertEqual(
         etree.tostring(comment.to_xml()),
         '<comment><![CDATA[<div>My comment 2</div>]]></comment>')
     try:
         obj = factory.load('tests/exercise-notvalid.xml')
         assert 0
     except etree.DocumentInvalid, e:
         self.assertEqual(
             str(e),
             'Element comments content does not follow the DTD, expecting '
             '(comment)+, got (), line 17'
         )
コード例 #4
0
 def test_load(self):
     obj = factory.load('tests/exercise.xml')
     self.assertEqual(obj.tagname, 'Exercise')
     comment = obj['test'][1]['comments']['comment'][1]
     self.assertEqual(comment.text, '<div>My comment 2</div>')
     self.assertEqual(
         etree.tostring(comment.to_xml()),
         b'<comment><![CDATA[<div>My comment 2</div>]]></comment>')
     try:
         obj = factory.load('tests/exercise-notvalid.xml')
         assert 0
     except etree.DocumentInvalid as e:
         self.assertEqual(
             str(e),
             'Element comments content does not follow the DTD, expecting '
             '(comment)+, got (), line 17')
     obj = factory.load('tests/exercise-notvalid.xml', validate=False)
     self.assertEqual(obj.tagname, 'Exercise')
コード例 #5
0
    def test_generate_form_from_obj(self):
        obj = factory.load('tests/exercise.xml')
        html = factory.generate_form_from_obj(obj)
        self.assertTrue('<form method="POST" id="xmltool-form">' in html)
        self.assertTrue('id="_xml_filename" value=""' in html)

        html = factory.generate_form_from_obj(
            obj, form_attrs={'data-action': 'action'})
        self.assertTrue('<form method="POST" data-action="action" '
                        'id="xmltool-form">' in html)

        # Empty object
        dtd_url = 'tests/exercise.dtd'
        dic = dtd.DTD(dtd_url).parse()
        obj = dic['Exercise']()
        html = factory.generate_form_from_obj(obj)
        self.assertTrue('<form method="POST" id="xmltool-form">' in html)
        self.assertTrue('id="_xml_filename" value=""' in html)
コード例 #6
0
ファイル: test_factory.py プロジェクト: LeResKP/xmltool
    def test_generate_form_from_obj(self):
        obj = factory.load('tests/exercise.xml')
        html = factory.generate_form_from_obj(obj)
        self.assertTrue('<form method="POST" id="xmltool-form">' in html)
        self.assertTrue('id="_xml_filename" value=""' in html)

        html = factory.generate_form_from_obj(
            obj,
            form_attrs={'data-action': 'action'})
        self.assertTrue('<form method="POST" data-action="action" '
                        'id="xmltool-form">' in html)

        # Empty object
        dtd_url = 'tests/exercise.dtd'
        dic = dtd.DTD(dtd_url).parse()
        obj = dic['Exercise']()
        html = factory.generate_form_from_obj(obj)
        self.assertTrue('<form method="POST" id="xmltool-form">' in html)
        self.assertTrue('id="_xml_filename" value=""' in html)
コード例 #7
0
ファイル: test_factory.py プロジェクト: samjy/xmltool
 def test_generate_form_from_obj(self):
     obj = factory.load('tests/exercise.xml')
     html = factory.generate_form_from_obj(obj)
     self.assertTrue('<form method="POST" id="xmltool-form">' in html)