configurationengine/source/plugins/common/ConeContentPlugin/contentplugin/tests/unittest_content_plugin.py
author m2lahtel
Thu, 21 Oct 2010 16:36:53 +0300
changeset 5 d2c80f5cab53
parent 3 e7e0ae78773e
permissions -rw-r--r--
Updated to version 1.2.14
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
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    21
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
from cone.public import exceptions,plugin,api,container
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
from cone.storage import filestorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
from contentplugin import contentml
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
# Hardcoded value of testdata folder that must be under the current working dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
testdata  = os.path.join(ROOT_PATH,'contentproject')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
class TestContentPlugin(unittest.TestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
	    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
    def test_create_copy_list_from_datacontainer_with_test(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        copylist = impl.create_copy_list(content=data, input='test',output='content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        self.assertEquals(copylist[0][1],'content/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
    def test_create_copy_list_from_datacontainer_with_defauls(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        copylist = impl.create_copy_list(content=data)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        self.assertEquals(copylist[0][0],'/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        self.assertEquals(copylist[0][1],'test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        self.assertEquals(copylist[1][0],'/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        self.assertEquals(copylist[1][1],'include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
    def test_create_copy_list_from_datacontainer_with_filters(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        copylist = impl.create_copy_list(content=data,input='include',include_filter='*.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        self.assertEquals(copylist[0][0],'/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        self.assertEquals(copylist[0][1],'hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
class TestContentPluginOnFileStorage(unittest.TestCase):    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
    def setUp(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
        self.curdir = os.getcwd()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        self.output = 'output'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        self.workdir = 'workdir'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
        if not os.path.exists(self.workdir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
            os.mkdir(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
        os.chdir(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    88
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    89
    def tearDown(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
    	os.chdir(self.curdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
        if os.path.exists(self.workdir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
            shutil.rmtree(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
            pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
    def load_config(self, config='product.confml'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
        return p.get_configuration(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
    def load_impl(self, resource_ref, config='product.confml'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
        configuration = self.load_config(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
        impls = plugin.ImplFactory.get_impls_from_file(resource_ref, configuration)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
        self.assertEquals(len(impls), 1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
        impl = impls[0]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
        return impl
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
    def test_configuration_parse_resource(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
        impl = self.load_impl('assets/s60/implml/test_filter_both.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
        self.assertEquals(impl.outputs[0].dir,'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
        self.assertEquals(impl.outputs[0].inputs[0].include,{'pattern': ['prod']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
        self.assertEquals(impl.outputs[0].inputs[0].exclude,{'pattern': ['.svn']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        self.assertEquals(impl.get_tags(), {'target': ['rofs3', 'uda']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
    def test_configuration_parse_content2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
        impl = self.load_impl('assets/s60/implml/content2_with_tags.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
        self.assertEquals(impl.outputs[0].dir,'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
        self.assertEquals(impl.outputs[0].inputs[0].include,{'files': ['test/override.txt, test/s60.txt']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
        self.assertEquals(impl.get_tags(), {'target': ['rofs3', 'uda']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   121
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   122
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   123
    def test_configuration_parse_content2_with_tag_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   124
        impl = self.load_impl('assets/s60/implml/content2_with_tags_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   125
        self.assertEquals(impl.get_tags(), {'target': ['rofs3']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   126
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   127
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   128
    def test_configuration_parse_and_filter_implementation_with_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   129
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   130
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
        config = p.get_configuration('product.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
        impls = plugin.get_impl_set(config,'\.content$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
        impls_rofs3 = impls.filter_implementations(tags={'target':['rofs3']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
        self.assertEquals(len(list(impls_rofs3)),3)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
    def test_configuration_parse_content_with_include_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
        impl = self.load_impl('assets/s60/implml/copy_files.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
        self.assertEquals(impl.outputs[0].inputs[0].include['files'],['test/override.txt, test/s60.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
    def test_configuration_content_get_full_copy_list(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   141
        impl = self.load_impl('assets/s60/implml/copy_files.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
        files = impl.get_full_copy_list()
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   143
        self.assertEquals(files,
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   144
            [('assets/s60/content/test/s60.txt', 'content/test/s60.txt', False),
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   145
             ('family/content/test/override.txt', 'content/test/override.txt', False)])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   146
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   147
    def test_configuration_content_list_output_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   148
        config = self.load_config()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   149
        impls = plugin.get_impl_set(config,'\.content$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   150
        files = impls.list_output_files()
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   151
        self.assertTrue('content/test/override.txt' in files)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
    def test_configuration_content_list_output_files_with_refs_filter(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
        impl = self.load_impl('assets/s60/implml/test_content_with_sequence_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   155
        files = impl.list_output_files()
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   156
        self.assertEquals(files[0],'content/override.txt')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   158
    def test_configuration_content_list_output_files_with_exclude_filter(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   159
        impl = self.load_impl('assets/s60/implml/test_filter_both.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
        files = impl.list_output_files()
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   161
        self.assertEquals(files[0],'content/prodX/jee/ProdX_specific.txt')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   162
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   163
    def test_configuration_get_input_with_ref(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   164
        impl = self.load_impl('assets/s60/implml/test_content_with_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
        self.assertEquals(impl.outputs[0].dir, 'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   166
        self.assertEquals(impl.outputs[0].inputs[0].dir, 'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   168
    def test_configuration_get_include_with_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
        impl = self.load_impl('assets/s60/implml/test_content_with_sequence_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
        self.assertEquals(impl.outputs[0].inputs[0].include['files'], ['test/override.txt'])
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   171
        self.assertEquals(impl.list_output_files(), ['content/override.txt'])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   173
    def test_configuration_get_include_with_refs2(self):
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
        impl = self.load_impl('assets/s60/implml/copy.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   175
        expected = ['content/prodX/jee/ProdX_specific.txt', 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   176
                    'content/test/shout.txt', 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   177
                    'content/test/override.txt', 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   178
                    'content/test/s60.txt',
5
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   179
                    'content/test/test_CAP_letters.txt',
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   180
                    'content/wallpapers/wallpaper1.png',
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   181
                    'content/wallpapers/wallpaper2.png',
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   182
                    'content/wallpapers/wallpaper3.png']
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   183
        actual = impl.list_output_files()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
        self.assertEquals(sorted(actual), sorted(expected))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
    def test_configuration_content_create_output(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        impl = self.load_impl('assets/s60/implml/copy.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
        impl.logger.setLevel(logging.DEBUG)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
        impl.create_output()
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   190
        self.assertTrue(os.path.exists(os.path.join(self.output,'content/prodX/jee/ProdX_specific.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   191
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   192
    def test_configuration_content_generate(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   193
        config = self.load_config()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   194
        impls = plugin.get_impl_set(config,'\.content$')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   195
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   196
        results = impls.generate(context)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
        self.assertTrue(os.path.exists(impls.output))
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   198
        self.assertTrue(os.path.exists(os.path.join(context.output,'content/prodX/jee/ProdX_specific.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   199
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   200
    def test_configuration_content_generate_with_include_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   201
        impl = self.load_impl('assets/s60/implml/test_content_with_sequence_refs.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   202
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   203
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   204
        self.assertTrue(os.path.exists(os.path.join(context.output,'content/override.txt')))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   205
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   206
    def test_configuration_content_generate_with_external_input(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   207
        impl = self.load_impl('assets/s60/implml/test_external_input.content')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   208
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   209
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   210
        self.assertTrue(os.path.exists(os.path.join(context.output,'content_external/abc.txt')))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   211
        self.assertTrue(os.path.exists(os.path.join(context.output,'content_external/folder1/data.txt')))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   212
        self.assertTrue(os.path.exists(os.path.join(context.output,'content_external2/folder2/setting.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
    def test_configuration_content_generate_with_multi_output(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
        impl = self.load_impl('assets/s60/implml/content2_with_multi_outputs.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   216
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   217
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   218
        self.assertTrue(os.path.exists(os.path.join(context.output,'content/test/override.txt')))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   219
        self.assertTrue(os.path.exists(os.path.join(context.output,'include/s60.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   221
    def test_configuration_content_generate_with_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
        impl = self.load_impl('assets/s60/implml/test_content_with_refs2.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   223
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   224
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   225
        self.assertTrue(os.path.exists(os.path.join(context.output,'content2p1/content2p2/override.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   227
    def test_configuration_content_generate_with_refs2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   228
        impl = self.load_impl('assets/s60/implml/test_content_with_refs3.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   229
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   230
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   231
        self.assertTrue(os.path.exists(os.path.join(self.output,'example/content2p2/override.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   232
       
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   233
    def test_configuration_content_generate_capital_letters(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   234
        impl = self.load_impl('assets/s60/implml/test_content_capital_file_input.content')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   235
        context = plugin.GenerationContext(output=self.output)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   236
        results = impl.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   237
        self.assertTrue(os.path.exists(context.output))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   238
        self.assertTrue(os.path.exists(os.path.join(context.output,'content/test_CAP_letters.txt')))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   239
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   240
    def test_get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   241
        def check(filename, expected_refs):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   242
            impl = self.load_impl('assets/s60/implml/' + filename)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   243
            actual_refs = impl.get_refs()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   244
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   245
            if expected_refs is None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   246
                self.assertEquals(actual_refs, None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   247
            else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   248
                self.assertTrue(actual_refs is not None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   249
                self.assertEquals(sorted(actual_refs), sorted(expected_refs))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   250
       
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   251
        check('content2_with_multi_outputs.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   252
        check('content2_with_tags_refs.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   253
        check('content2_with_tags.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   254
        check('copy_files.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   255
        check('copy.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   256
        check('test_content_with_refs.content', ['content.inputdir'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   257
        check('test_content_with_refs2.content', ['content.inputdir2'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   258
        check('test_content_with_refs3.content', ['content.inputdir2'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   259
        check('test_content_with_sequence_refs.content', ['ContentFiles.contentfile.fileelem.localPath'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   260
        check('test_external_input.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   261
        check('test_external_with_ref.content', ['CTD_Special.InputPath'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   262
        check('test_filter_both.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   263
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   264
    def test_uses_layer(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   265
        project = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'contentproject')))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   266
        root_config = project.get_configuration('product.confml')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   267
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   268
        impl = self.load_impl('assets/s60/implml/test_content_capital_file_input.content')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   269
        self.assertFalse(impl.uses_layer(root_config.get_configuration_by_index(0)))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   270
        self.assertFalse(impl.uses_layer(root_config.get_configuration_by_index(1)))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   271
        self.assertTrue(impl.uses_layer(root_config.get_configuration_by_index(2)))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   272
    
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   273
    def test_get_copy_list_with_empty_file_input_from_sequence(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   274
        impl = self.load_impl('assets/s60/implml/empty_input_file_from_sequence.content')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   275
        copylist = impl.get_full_copy_list()
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   276
        # There should be nothing in the copy list
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   277
        self.assertEquals(copylist, [])
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   278
        
5
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   279
    def test_get_copy_list_with_multiple_includes_from_sequence(self):
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   280
        impl = self.load_impl('assets/s60/implml/multiple_input_includes_from_sequence.content')
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   281
        copylist = impl.get_full_copy_list()
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   282
        self.assertEquals(sorted(copylist),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   283
            sorted(
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   284
                [('assets/s60/content/test/foo.txt', 'widget/temp/foo.txt', False),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   285
                 ('assets/s60/content/test/bar.txt', 'widget/temp/bar.txt', False),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   286
                 ('assets/s60/content/test/baz.txt', 'widget/temp/baz.txt', False),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   287
                 ('assets/s60/content/test/s60.txt', 'widget/temp/s60.txt', False)]))
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   288
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   289
    def test_get_copy_list_with_multiple_input_from_sequence_with_flatten(self):
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   290
        impl = self.load_impl('assets/s60/implml/multiple_input_from_sequence_with_flatten.content')
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   291
        copylist = impl.get_full_copy_list()
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   292
        self.assertEquals(sorted(copylist),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   293
            sorted(
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   294
                [('family/product/content/wallpapers/wallpaper1.png', 'content/wallpapers/1_wallpaper1.png', False),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   295
                 ('family/product/content/wallpapers/wallpaper2.png', 'content/wallpapers/2_wallpaper2.png', False),
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   296
                 ('family/product/content/wallpapers/wallpaper3.png', 'content/wallpapers/3_wallpaper3.png', False)]))
d2c80f5cab53 Updated to version 1.2.14
m2lahtel
parents: 3
diff changeset
   297
        
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   298
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   299
    unittest.main()