0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
"""
|
|
18 |
Test the CPF root file parsing routines
|
|
19 |
"""
|
|
20 |
|
|
21 |
import unittest
|
|
22 |
import string
|
|
23 |
import sys
|
|
24 |
import os
|
|
25 |
import shutil
|
|
26 |
|
|
27 |
from cone.public import api, exceptions, persistence
|
|
28 |
from cone.storage import filestorage
|
|
29 |
from cone.confml import persistentconfml, model, confmltree
|
|
30 |
|
|
31 |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
|
32 |
|
|
33 |
class TestConfmlXml(unittest.TestCase):
|
|
34 |
|
|
35 |
def test_namespaces(self):
|
|
36 |
root = confmltree.Element('root')
|
|
37 |
elem = confmltree.Element('{http://spam.effbot.org}egg')
|
|
38 |
root.append(elem)
|
|
39 |
elem.append(confmltree.Element('{http://spam.effbot.org}ham'))
|
|
40 |
elem.append(confmltree.Element('{http://test.com}foo'))
|
|
41 |
str = confmltree.tostring(root, {'http://spam.effbot.org': 'ham',
|
|
42 |
'http://test.com': 'bar'})
|
|
43 |
et = confmltree.fromstring(str)
|
|
44 |
self.assertTrue(et)
|
|
45 |
self.assertEquals(str,'<root xmlns:bar="http://test.com" xmlns:ham="http://spam.effbot.org"><ham:egg><ham:ham /><bar:foo /></ham:egg></root>')
|
|
46 |
|
|
47 |
|
|
48 |
if __name__ == '__main__':
|
|
49 |
unittest.main()
|