configurationengine/source/plugins/example/ConeExamplePlugin/examplemlplugin/tests/unittest_exampleml_generation.py
author m2lahtel
Tue, 10 Aug 2010 14:29:28 +0300
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
permissions -rw-r--r--
ConE 1.2.11 release
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
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    17
import os
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from testautomation.base_testcase import BaseTestCase
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    22
from cone.public import plugin, api
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
def abspath(path):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
    return os.path.normpath(os.path.join(ROOT_PATH, path))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
class TestExamplemlGeneration(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
    def test_generate_from_project(self):
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    31
        project_dir     = abspath('testdata/generation/project')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
        config          = 'root.confml'
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    33
        output_dir      = abspath('temp/generation/output')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    34
        expected_dir    = abspath('testdata/generation/expected')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        config = prj.get_configuration(config)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    40
        context = plugin.GenerationContext(configuration=config, 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    41
                                           output=output_dir)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        impls = plugin.get_impl_set(config)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    43
        impls.generate(context)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46