configurationengine/source/plugins/symbian/ConeProjectConverterPlugin/projectconvertplugin/tests/unittest_convertprojectml_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, os, shutil
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
import __init__	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
from projectconvertplugin  import convertproject
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from cone.public import exceptions,plugin,api
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
from cone.storage import filestorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
from cone.confml import implml
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from testautomation.base_testcase import BaseTestCase
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
temp_dir  = os.path.join(ROOT_PATH, "temp")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
testdata  = os.path.join(ROOT_PATH,'project')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
class TestConvertProjectPlugin(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_example_parse_prj(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        output_dir = os.path.join(temp_dir, "new_project2")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        if os.path.exists(output_dir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
            shutil.rmtree(output_dir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        config = p.get_configuration('product.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        impls = plugin.get_impl_set(config, r'file1\.convertprojectml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        self.assertEquals(1, len(impls))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        impl = iter(impls).next()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
    def test_generate(self):
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')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        impls = plugin.get_impl_set(config,'\.convertprojectml$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        impls.output = output_dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        impls.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
  unittest.main()