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