configurationengine/source/plugins/symbian/ConeCRMLPlugin/CRMLPlugin/tests/unittest_txt_generation.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 sys, os, unittest
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
import __init__
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
from testautomation.base_testcase import BaseTestCase
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
from cone.public import exceptions, plugin, api, container
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
from CRMLPlugin import crml_impl
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
def abspath(path):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
    return os.path.normpath(os.path.join(ROOT_PATH, path))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
class TestCrmlImpl(BaseTestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
    def test_generate_from_project_with_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        project_dir     = abspath('gen_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        output_dir      = abspath('temp/gen_output1')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        expected_dir    = abspath('gen_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        config = prj.get_configuration(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        impls = plugin.get_impl_set(config, 'crml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        impls.output = output_dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        impls.generation_context.tags['target'] = ['rofs2']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        impls.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        impls.post_generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
    def test_generate_from_project_without_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        project_dir     = abspath('gen_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        output_dir      = abspath('temp/gen_output2')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        expected_dir    = abspath('gen_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        config = prj.get_configuration(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        impls = plugin.get_impl_set(config, 'crml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        impls.output = output_dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        impls.generation_context.tags['target'] = []
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        impls.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
        impls.post_generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn', 'private'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        self.assertFalse(os.path.exists(os.path.join(output_dir, 'private/100059C9/cenrep_rfs.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
    def test_generate_from_project_duplicate_rfs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        project_dir     = abspath('duplicate_rfs_project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        config          = 'root.confml'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        output_dir      = abspath('temp/duplicate_rfs_output')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        expected_dir    = abspath('duplicate_rfs_expected')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        self.remove_if_exists(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        prj = api.Project(api.Storage.open(project_dir))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
        config = prj.get_configuration(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
        impls = plugin.get_impl_set(config, 'crml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
        impls.output = output_dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        impls.generation_context.tags['target'] = ['rofs2']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        impls.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
        impls.post_generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
        self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87