/[thuban]/branches/WIP-pyshapelib-bramz/test/test_xmlsupport.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/test/test_xmlsupport.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1257 - (hide annotations)
Fri Jun 20 12:22:25 2003 UTC (21 years, 8 months ago) by bh
Original Path: trunk/thuban/test/test_xmlsupport.py
File MIME type: text/x-python
File size: 2942 byte(s)
* test/test_load.py (LoadSessionTest.check_format): New helper
method to make sure the test files we load might have been written
by the current thuban version.
(ClassificationTest.TestLayers, TestSingleLayer.test)
(TestLayerVisibility.test, TestClassification.test)
(TestLabels.test, TestLayerProjection.test, TestRasterLayer.test):
Add check_format() calls and fix the thuban data to match the data
that would be written by saving the session loaded from it.

* test/xmlsupport.py (SaxEventLister, sax_eventlist): Copies of
the same class and function in test_save.

* test/test_xmlsupport.py (TestEventList): New. test cases for
sax_eventlist

1 bh 1245 # Copyright (C) 2003 by Intevation GmbH
2     # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with the software for details.
7    
8     """Test for the xmlsupport.py module
9     """
10    
11     __version__ = "$Revision$"
12     # $Source$
13     # $Id$
14    
15     import unittest
16    
17     import xmlsupport
18     import support
19    
20     class TestValidation(unittest.TestCase, xmlsupport.ValidationTest):
21    
22     def test_simple(self):
23     """test xmlsupport validating valid XML
24    
25     The test succeeds if validate_data doesn't raise any exception
26     """
27     data = ('<?xml version="1.0" encoding="UTF-8"?>\n'
28     '<!DOCTYPE session SYSTEM "thuban.dtd">\n'
29     '<session title="empty session">\n</session>\n')
30     self.validate_data(data)
31    
32     def test_invalid(self):
33     """test xmlsupport validating invalid XML
34    
35     The test succeeds if validate_data raises an assertion error
36     """
37     data = ('<?xml version="1.0" encoding="UTF-8"?>\n'
38     '<!DOCTYPE session SYSTEM "thuban.dtd">\n'
39     '<session foo="bar">\n</session>\n')
40     # only really run this test when pyRXP is available
41     if xmlsupport.pyRXP is not None:
42     self.assertRaises(AssertionError, self.validate_data, data)
43    
44    
45 bh 1257
46     class TestEventList(unittest.TestCase):
47    
48     """Test cases for sax_eventlist"""
49    
50     def test_even_list_simple(self):
51     """Test sax_eventlist on very simple XML"""
52     data = "\n".join(['<?xml version="1.0" encoding="UTF-8"?>'
53     '<!DOCTYPE session SYSTEM "thuban.dtd">'
54     '<session title="single map&amp;layer">'
55     '</session>'])
56    
57     self.assertEquals(xmlsupport.sax_eventlist(data = data),
58     [('start', (None, u'session'), None,
59     [((None, u'title'), u'single map&layer')]),
60     ('end', (None, u'session'), None)])
61    
62     def test_even_list_namespace(self):
63     """Test sax_eventlist on XML with a default namespace"""
64     data = "\n".join(['<?xml version="1.0" encoding="UTF-8"?>'
65     '<!DOCTYPE session SYSTEM "thuban.dtd">'
66     '<session title="single map&amp;layer"'
67     ' xmlns="http://example.com/example.dtd">'
68     '</session>'])
69    
70     self.assertEquals(xmlsupport.sax_eventlist(data = data),
71     [('start', (u'http://example.com/example.dtd',
72     u'session'),
73     None, [((None, u'title'), u'single map&layer')]),
74     ('end', (u'http://example.com/example.dtd',
75     u'session'), None)])
76    
77 bh 1245 if __name__ == "__main__":
78     # Fake the __file__ global because it's needed by a test
79     import sys
80     __file__ = sys.argv[0]
81     support.run_tests()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26