buildframework/helium/sf/python/pythoncore/lib/pythoncoretests/test_configuration.py
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    16 #
    16 #
    17 #Description:
    17 #Description:
    18 #===============================================================================
    18 #===============================================================================
    19 """ test configuration """
    19 """ test configuration """
    20 
    20 
    21 # pylint: disable-msg=R0201
    21 # pylint: disable=R0201
    22 
    22 
    23 import logging
    23 import logging
    24 import StringIO
    24 import StringIO
    25 import unittest
    25 import unittest
    26 import os
    26 import os
    61 
    61 
    62         configs = config_set.getConfigurations('spec.with.type')
    62         configs = config_set.getConfigurations('spec.with.type')
    63         assert len(configs) == 1
    63         assert len(configs) == 1
    64         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    64         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    65         
    65         
    66         configs = config_set.getConfigurations(type='test.type')
    66         configs = config_set.getConfigurations(type_='test.type')
    67         assert len(configs) == 2
    67         assert len(configs) == 2
    68         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    68         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    69 
    69 
    70         configs = config_set.getConfigurations(name='test_spec', type='test.type')
    70         configs = config_set.getConfigurations(name='test_spec', type_='test.type')
    71         assert len(configs) == 2
    71         assert len(configs) == 2
    72         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    72         assert configs[0].type == 'test.type', "config.type must match 'test.type'."
    73         
    73         
    74     def test_append(self):
    74     def test_append(self):
    75         """A child value can be appended to a parent value."""
    75         """A child value can be appended to a parent value."""
   260         assert config['text.a'] == 'text.value.A'
   260         assert config['text.a'] == 'text.value.A'
   261         assert config['text.b'] == 'text.value.B'
   261         assert config['text.b'] == 'text.value.B'
   262         assert config['foo'] == 'bar'
   262         assert config['foo'] == 'bar'
   263         
   263         
   264         
   264         
   265 if 'java' not in sys.platform:
       
   266     class XMLConfigurationTest(unittest.TestCase):
       
   267         """ Test XML format configuration files. """
       
   268         
       
   269         def test_single_node_xml(self):
       
   270             """ Properties can be read from 1 level of XML sub-elements. """
       
   271             config = configuration.XMLConfiguration(open(os.path.join(os.environ['TEST_DATA'], 'data/ant_config_test.xml'), 'r'))
       
   272             
       
   273             assert config['foo'] == 'bar'
       
   274             assert config['interpolated'] == 'foo value = bar'
       
   275             
       
   276         def test_nested_node_xml(self):
       
   277             """ Properties can be read from multiple levels of XML sub-elements. """
       
   278             config = configuration.XMLConfiguration(open(os.path.join(os.environ['TEST_DATA'], 'data/ant_config_test.xml'), 'r'))
       
   279             
       
   280             assert config['xml.c'] == 'C'
       
   281             
       
   282         def test_xml_list(self):
       
   283             """ Multiple XML elements can be read as a list. """
       
   284             config = configuration.XMLConfiguration(open(os.path.join(os.environ['TEST_DATA'], 'data/ant_config_test.xml'), 'r'))
       
   285             
       
   286             assert config['array.value'] == 'one,two,three'
       
   287