configurationengine/source/plugins/symbian/ConeProjectConverterPlugin/projectconvertplugin/tests/unittest_convertprojectml_plugin.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
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
import unittest, os, shutil
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
from projectconvertplugin  import convertproject
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    20
from cone.public import plugin,api
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from cone.storage import filestorage
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
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
temp_dir  = os.path.join(ROOT_PATH, "temp")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
testdata  = os.path.join(ROOT_PATH,'project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
class TestConvertProjectPlugin(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_example_parse_prj(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
        output_dir = os.path.join(temp_dir, "new_project2")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
        if os.path.exists(output_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
            shutil.rmtree(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        config = p.get_configuration('product.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        impls = plugin.get_impl_set(config, r'file1\.convertprojectml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        self.assertEquals(1, len(impls))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        impl = iter(impls).next()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
    def test_generate(self):
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    44
        os.environ['ncp_version'] = 'platforms'
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    45
        os.environ['variants'] = 'variants'        
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        output_dir = os.path.join(temp_dir, "new_project")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
        if os.path.exists(output_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
            shutil.rmtree(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        expected_dir = os.path.join(ROOT_PATH, "expected/new_project")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        oldPath = os.path.join(ROOT_PATH,'old_structure/epoc32/rom/config')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
         
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        fs = filestorage.FileStorage(oldPath)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        config = p.get_configuration('convert.confml')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    55
        context = plugin.GenerationContext(configuration=config,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    56
                                           output=output_dir)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        impls = plugin.get_impl_set(config,'\.convertprojectml$')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    58
        context.filtering_disabled = True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    59
        impls.generate(context)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
if __name__ == '__main__':
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    65
    unittest.main()