Parent Directory
|
Revision Log
Add XML validation to some of the tests. Validation will only be done if pyRXP is installed (http://reportlab.com/xml/pyrxp.html). To make the DTD available to the test cases it's moved into Resources/XML * Resources/XML/thuban.dtd: New. This is now the real Thuban DTD for versions up to and including 0.2. Two slight changes: added an encoding specification and fixed the comment which refered to GRASS, not Thuban * test/xmlsupport.py: New support module for tests involving XML. Currently there's a mix-in class for XML validation. * test/test_xmlsupport.py: New. Tests for the xmlsupport module * test/test_save.py (SaveSessionTest): Derive from ValidationTest so that we can validate the (SaveSessionTest.testEmptySession) (SaveSessionTest.testSingleLayer) (SaveSessionTest.testSingleLayer) (SaveSessionTest.testLayerProjection) (SaveSessionTest.testRasterLayer) (SaveSessionTest.testClassifiedLayer): Validate the generated XML * test/runtests.py (main): Call print_additional_summary instead of print_garbage_information * test/support.py (resource_dir): New function to return the "Resource" subdirectory (print_additional_summary): New function to combine several summary functions (run_tests): Use print_additional_summary instead of calling print_garbage_information directly
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 | if __name__ == "__main__": | ||
46 | # Fake the __file__ global because it's needed by a test | ||
47 | import sys | ||
48 | __file__ = sys.argv[0] | ||
49 | support.run_tests() |
Name | Value |
---|---|
svn:eol-style | native |
svn:keywords | Author Date Id Revision |
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |