buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_atsconfiguration.py
author wbernard
Thu, 22 Jul 2010 17:08:43 +0300
branchhelium-9.0
changeset 618 df88fead2976
parent 587 85df38eb4012
permissions -rw-r--r--
helium_9.0.5-4399343f4f50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
# -*- encoding: latin-1 -*-
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
#Name    : test_ATSconfiguration.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
""" Testing the ATS configuration file """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import StringIO
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import configuration
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import ats3.parsers
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
_logger = logging.getLogger('test.atsconfiguration')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
logging.basicConfig(level=logging.INFO)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
def test_ATS_element():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    """ ATS elements can be used in configuration. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    config_text = """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
<ATSConfigData>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
    <config name="properties">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
    <set name="PA" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    <config name="attributes">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    <set name="attrs" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    <set name="AB" value="100"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    <set name="AC" value="101"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
</ATSConfigData>"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
    builder = configuration.NestedConfigurationBuilder(StringIO.StringIO(config_text))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    config = builder.getConfiguration().getConfigurations()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    assert config[0]['PA'] == 'foo'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
    assert config[1]['AB'] == '100'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
def test_ATS_config_attirbutes():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    """ ATS elements can be used attributes only. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
    config_text = """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
<ATSConfigData>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
    <config name="attributes">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    <set name="attrs" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    <set name="AB" value="100"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
    <set name="AC" value="101"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
</ATSConfigData>"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
    (params, attrs) = ats3.parsers.split_config_to_attributes_and_properties(StringIO.StringIO(config_text))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
    print attrs
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    print params
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
    assert params ==  {}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    assert attrs ==  {u'attrs': u'foo', u'AC': u'101', u'AB': u'100'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
def test_ATS_config_properties():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    """ ATS elements can be used properties only. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
    config_text = """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
<ATSConfigData>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    <config name="noattributes">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    <set name="attrs" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
    <set name="AB" value="100"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
    <set name="AC" value="101"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
    <config name="properties">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
    <set name="HW" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
</ATSConfigData>"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
    (params, attrs) = ats3.parsers.split_config_to_attributes_and_properties(StringIO.StringIO(config_text))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
    print attrs
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
    print params
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
    assert params ==  {u'HW': u'foo' }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
    assert attrs ==  { }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
def test_ATS_element3():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
    """ All alements can be used and several times. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
    config_text = """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
<ATSConfigData>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
    <config name="attributes">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
    <set name="attrs" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
    <set name="AB" value="100"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
    <set name="AC" value="101"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
    <config name="properties">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
    <set name="PA" value="foo"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
    <config name="properties">
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
    <set name="HW" value="bar"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
    </config>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
</ATSConfigData>"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
    	
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
    (params, attrs) = ats3.parsers.split_config_to_attributes_and_properties(StringIO.StringIO(config_text))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
    print attrs
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
    print params
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
    assert params ==  {u'PA': u'foo' , u'HW': u'bar'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
    assert attrs ==  {u'attrs': u'foo', u'AC': u'101', u'AB': u'100'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119