configurationengine/source/plugins/common/ConeContentPlugin/contentplugin/tests/unittest_content_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
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
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
import __init__
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
		
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
from cone.storage import filestorage
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
from contentplugin import contentml
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
# Hardcoded value of testdata folder that must be under the current working dir
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
testdata  = os.path.join(ROOT_PATH,'contentproject')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
class TestContentPlugin(unittest.TestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
	    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
    def test_create_copy_list_from_datacontainer_with_test(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        copylist = impl.create_copy_list(content=data, input='test',output='content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        self.assertEquals(copylist[0][1],'content/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
    def test_create_copy_list_from_datacontainer_with_defauls(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        copylist = impl.create_copy_list(content=data)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        self.assertEquals(copylist[0][0],'/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        self.assertEquals(copylist[0][1],'test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        self.assertEquals(copylist[1][0],'/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        self.assertEquals(copylist[1][1],'include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
    def test_create_copy_list_from_datacontainer_with_filters(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        Test that the loading of the plugins works
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        '''
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        data = container.DataContainer()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        data.add_value('test/test.txt','/foo/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        data.add_value('test/test.txt','/bar/content/test/test.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        data.add_value('product/aaa.txt','/foo/content/product/aaa.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        data.add_value('images/kuva.jpg','/foo/content/images/kuva.jpg')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        data.add_value('include/hide.iby','/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        impl = contentml.ContentImpl("foo",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        copylist = impl.create_copy_list(content=data,input='include',include_filter='*.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        self.assertEquals(copylist[0][0],'/bar/content/include/hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        self.assertEquals(copylist[0][1],'hide.iby')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
class TestContentPluginOnFileStorage(unittest.TestCase):    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
    def setUp(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        self.curdir = os.getcwd()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        self.output = 'output'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
        self.workdir = 'workdir'
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
        if not os.path.exists(self.workdir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
            os.mkdir(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
        os.chdir(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    88
        pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    89
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
    def tearDown(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
    	os.chdir(self.curdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
        if os.path.exists(self.workdir):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
            shutil.rmtree(self.workdir)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
            pass
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
    def load_config(self, config='product.confml'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
        return p.get_configuration(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
    
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
    def load_impl(self, resource_ref, config='product.confml'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
        configuration = self.load_config(config)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
        impls = plugin.ImplFactory.get_impls_from_file(resource_ref, configuration)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
        self.assertEquals(len(impls), 1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
        impl = impls[0]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
        return impl
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
    def test_configuration_parse_resource(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
        impl = self.load_impl('assets/s60/implml/test_filter_both.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
        self.assertEquals(impl.outputs[0].dir,'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        self.assertEquals(impl.outputs[0].inputs[0].include,{'pattern': ['prod']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
        self.assertEquals(impl.outputs[0].inputs[0].exclude,{'pattern': ['.svn']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
        self.assertEquals(impl.get_tags(), {'target': ['rofs3', 'uda']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
    def test_configuration_parse_content2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
        impl = self.load_impl('assets/s60/implml/content2_with_tags.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
        self.assertEquals(impl.outputs[0].dir,'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   121
        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
   122
        self.assertEquals(impl.get_tags(), {'target': ['rofs3', 'uda']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   123
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   124
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   125
    def test_configuration_parse_content2_with_tag_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   126
        impl = self.load_impl('assets/s60/implml/content2_with_tags_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   127
        self.assertEquals(impl.get_tags(), {'target': ['rofs3']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   128
        self.assertEquals(impl.has_tag({'target':['rofs3']}), True)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   129
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   130
    def test_configuration_parse_and_filter_implementation_with_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
        fs = filestorage.FileStorage(testdata)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
        p = api.Project(fs)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
        config = p.get_configuration('product.confml')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
        impls = plugin.get_impl_set(config,'\.content$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
        impls_rofs3 = impls.filter_implementations(tags={'target':['rofs3']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
        self.assertEquals(len(list(impls_rofs3)),3)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
    def test_configuration_parse_content_with_include_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
        impl = self.load_impl('assets/s60/implml/copy_files.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
        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
   141
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
    def test_configuration_content_get_full_copy_list(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   143
        impl = self.load_impl('assets/s60/implml/copy_files.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   144
        files = impl.get_full_copy_list()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   145
        self.assertEquals(files[0],('family/content/test/override.txt', 'output/content/test/override.txt', False))
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
        impls.output = self.output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   151
        files = impls.list_output_files()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
        self.assertTrue('output/content/test/override.txt' in files)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
    def test_configuration_content_list_output_files_with_refs_filter(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   155
        impl = self.load_impl('assets/s60/implml/test_content_with_sequence_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   156
        files = impl.list_output_files()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
        self.assertEquals(files[0],'output/content/override.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   158
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   159
    def test_configuration_content_list_output_files_with_exclude_filter(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
        impl = self.load_impl('assets/s60/implml/test_filter_both.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   161
        files = impl.list_output_files()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   162
        self.assertEquals(files[0],'output/content/prodX/jee/ProdX_specific.txt')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   163
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   164
    def test_configuration_get_input_with_ref(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
        impl = self.load_impl('assets/s60/implml/test_content_with_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   166
        self.assertEquals(impl.outputs[0].dir, 'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
        self.assertEquals(impl.outputs[0].inputs[0].dir, 'content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   168
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
    def test_configuration_get_include_with_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
        impl = self.load_impl('assets/s60/implml/test_content_with_sequence_refs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   171
        self.assertEquals(impl.outputs[0].inputs[0].include['files'], ['test/override.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
        self.assertEquals(impl.list_output_files(), ['output/content/override.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   173
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
    def test_configuration_get_include_with_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   175
        impl = self.load_impl('assets/s60/implml/copy.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   176
        expected = ['output/content/prodX/jee/ProdX_specific.txt', 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   177
                    'output/content/test/shout.txt', 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   178
                    'output/content/test/override.txt', 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   179
                    'output/content/test/s60.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   180
                    'output/content/test/test_CAP_letters.txt']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   181
        actual = impl.list_output_files()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   182
        self.assertEquals(sorted(actual), sorted(expected))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   183
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
    def test_configuration_content_create_output(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
        impl = self.load_impl('assets/s60/implml/copy.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        impl.logger.setLevel(logging.DEBUG)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
        impl.create_output()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   190
        self.assertTrue(os.path.exists(os.path.join(impl.output,'content/prodX/jee/ProdX_specific.txt')))
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$')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   195
        impls.output = self.output
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   196
        results = impls.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
        self.assertTrue(os.path.exists(impls.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   198
        self.assertTrue(os.path.exists(os.path.join(impls.output,'content/prodX/jee/ProdX_specific.txt')))
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')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   202
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   203
        results = impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   204
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   205
        self.assertTrue(os.path.exists(os.path.join(impl.output,'content/override.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   206
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   207
    def test_configuration_content_generate_with_multi_output(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   208
        impl = self.load_impl('assets/s60/implml/content2_with_multi_outputs.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   209
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   210
        results = impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   211
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   212
        self.assertTrue(os.path.exists(os.path.join(impl.output,'content/test/override.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
        self.assertTrue(os.path.exists(os.path.join(impl.output,'include/s60.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
    def test_configuration_content_generate_with_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   216
        impl = self.load_impl('assets/s60/implml/test_content_with_refs2.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   217
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   218
        results = impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   219
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
        self.assertTrue(os.path.exists(os.path.join(impl.output,'content2p1/content2p2/override.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   221
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
    def test_configuration_content_generate_with_refs2(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   223
        impl = self.load_impl('assets/s60/implml/test_content_with_refs3.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   224
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   225
        results = impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   227
        self.assertTrue(os.path.exists(os.path.join(impl.output,'example/content2p2/override.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   228
       
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   229
    def test_configuration_content_generate_capital_letters(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   230
        impl = self.load_impl('assets/s60/implml/test_content_capital_file_input.content')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   231
        impl.set_output_root(self.output)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   232
        results = impl.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   233
        self.assertTrue(os.path.exists(impl.output))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   234
        self.assertTrue(os.path.exists(os.path.join(impl.output,'content/test_CAP_letters.txt')))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   235
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   236
    def test_get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   237
        def check(filename, expected_refs):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   238
            impl = self.load_impl('assets/s60/implml/' + filename)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   239
            actual_refs = impl.get_refs()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   240
            
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   241
            if expected_refs is None:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   242
                self.assertEquals(actual_refs, None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   243
            else:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   244
                self.assertTrue(actual_refs is not None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   245
                self.assertEquals(sorted(actual_refs), sorted(expected_refs))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   246
       
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   247
        check('content2_with_multi_outputs.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   248
        check('content2_with_tags_refs.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   249
        check('content2_with_tags.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   250
        check('copy_files.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   251
        check('copy.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   252
        check('test_content_with_refs.content', ['content.inputdir'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   253
        check('test_content_with_refs2.content', ['content.inputdir2'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   254
        check('test_content_with_refs3.content', ['content.inputdir2'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   255
        check('test_content_with_sequence_refs.content', ['ContentFiles.contentfile.fileelem.localPath'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   256
        check('test_external_input.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   257
        check('test_external_with_ref.content', ['CTD_Special.InputPath'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   258
        check('test_filter_both.content', None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   259
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   260
if __name__ == '__main__':
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   261
    unittest.main()