configurationengine/source/plugins/common/ConeRulePlugin/ruleplugin/tests/unittest_rule_empty_plugin.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
import unittest
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
import os, shutil
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
import sys
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
import logging
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
import __init__
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from cone.public import exceptions,plugin,api,container
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
from cone.storage import filestorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
from ruleplugin import ruleml
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
# Hardcoded value of testdata folder that must be under the current working dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
testdata  = os.path.join(ROOT_PATH,'rule')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
class TestRuleEmptyPlugin(unittest.TestCase):    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
    def setUp(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
      
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
    def tearDown(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
    def test_rule_with_empty_value1(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        return
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'ruleproject/rules'), "a" ))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        config = project.get_configuration('root.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        implcontainer = plugin.get_impl_set(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        implcontainer.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        lastconfig = config.get_last_configuration()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
        self.assertEquals(lastconfig.get_path(),ruleml.RuleImpl.AUTOCONFIGURATION_CONFML)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        self.assertEquals(lastconfig.get_data('imakerapi.outputLocation').get_ref(),'outputLocation')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        self.assertEquals(lastconfig.get_data('imakerapi.outputLocation').get_value(),'2')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        self.assertEquals(lastconfig.get_data('imakerapi.outputLocationY').get_value(),'hello')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        self.assertEquals(lastconfig.get_data('operations.minus').get_value(),'18')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        self.assertEquals(lastconfig.get_data('operations.minus1').get_value(),'35')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        self.assertEquals(lastconfig.get_data('operations.minus4').get_value(),'5')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        project.close()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
    def test_rule_with_empty_value2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        return
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'rule/config_project/platforms/customsw'), "a" ))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        config = project.get_configuration('root.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        implcontainer = plugin.get_impl_set(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        implcontainer.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        lastconfig = config.get_last_configuration()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
        self.assertEquals(lastconfig.get_data('operations.minus').get_value(),'18')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        self.assertEquals(lastconfig.get_data('operations.minus1').get_value(),'35')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        self.assertEquals(lastconfig.get_data('operations.minus4').get_value(),'5')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        self.assertEquals(lastconfig.get_data('operations.minus6').get_value(),'19')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        self.assertEquals(lastconfig.get_data('operations.string1').get_value(),'HelloWorld')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        project.close()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
    unittest.main()