configurationengine/source/cone/public/tests/unittest_plugin_implcontainer.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
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
import logging
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
import __init__
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
from cone.public import *
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
class TestPluginImplContainer(unittest.TestCase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
    class ImplTest(plugin.ImplBase):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
        def __init__(self,ref,configuration):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
            plugin.ImplBase.__init__(self,ref,configuration)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
            self.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
            self.refs = ["dummy1.too"]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
            self.output_files = []
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
        def generate(self, context=None):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
            self.generate_invoked = True
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
            if context and hasattr(context, 'objects'):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
                context.objects.append(self)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
        def get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
            return self.refs
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        def list_output_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
            return self.output_files
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
    def test_impl_container_add(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
        imp1  = plugin.ImplBase("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
        imp2a = plugin.ImplBase("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
        imp2b = plugin.ImplBase("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
        self.assertEquals(container.impls, [imp1,imp2a, imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
    def test_impl_container_sub_container(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
        imp1  = plugin.ImplBase("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        imp2a = plugin.ImplBase("implml/sub.implml:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        imp2b = plugin.ImplBase("implml/sub.implml:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
        self.assertEquals(container.get_all_implementations(),[imp1,imp2a,imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        for sub in container:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
            print sub
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
        container[0] = subcontainer
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        self.assertEquals(container.impls, [subcontainer,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        del container[0]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        self.assertEquals(container.impls, [subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
    def test_impl_container_with_condition(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        context.configuration = api.Configuration()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        context.configuration.add_feature(api.Feature("test"))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        context.configuration.add_feature(api.Feature("stringsub"),"test")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        context.configuration.add_feature(api.Feature("intsub"),"test")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
        context.configuration.get_default_view().test.value = True
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
        context.configuration.get_default_view().test.stringsub.value = "stringval"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
        context.configuration.get_default_view().test.intsub.value = 2
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        condition = rules.SimpleCondition("${test}", "true")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
        container.condition = condition
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    86
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    87
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    88
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    89
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
        context.configuration.get_default_view().test.value = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
        condition = rules.SimpleCondition("${test}", "false")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
        container.condition = condition
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
        context.configuration.get_default_view().test.value = True
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
    def test_impl_container_generate(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
        container.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
    def test_impl_container_get_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   121
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   122
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   123
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   124
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   125
        subcontainer = plugin.ImplContainer("sub", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   126
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   127
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   128
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   129
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   130
        self.assertEquals(container.get_tags(), {})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
        container.set_tags({'test':['foobar']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
        self.assertEquals(container.get_tags(), {'test':['foobar']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
        imp1.set_tags({'foo':['bar']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
        self.assertEquals(container.get_tags(), {'test':['foobar'],
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
                                                 'foo':['bar']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
        imp2a.set_tags({'test':['bar'], 'one' :['more']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
        self.assertEquals(container.get_tags(), {'test':['foobar', 'bar'],
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
                                                 'foo':['bar'],
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
                                                 'one' :['more']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   141
        subcontainer.set_tags({'test':['bar1']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
        self.assertEquals(container.get_tags(), {'test':['foobar', 'bar', 'bar1'],
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   143
                                                 'foo':['bar'],
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   144
                                                 'one' :['more']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   145
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   146
    def test_impl_container_get_phase(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   147
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   148
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   149
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   150
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   151
        subcontainer1 = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
        subcontainer1.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   155
        subcontainer1.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   156
        subcontainer1.set_invocation_phase("normal")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
        self.assertEquals(container.invocation_phase(), ["normal"])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   158
        imp1.set_invocation_phase('pre')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   159
        self.assertEquals(container.invocation_phase(), ["normal"])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
        subcontainer2 = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   161
        subimp = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   162
        subimp.set_invocation_phase('post')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   163
        subcontainer2.append(subimp)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   164
        subcontainer2.set_invocation_phase('post')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
        container.append(subcontainer2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   166
        self.assertEquals(container.invocation_phase(), ['post','normal'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   168
    def test_impl_container_get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   171
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   173
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   175
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   176
        self.assertEquals(container.get_refs(), ["dummy1.too"])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   177
        imp2b.refs = ['dummy2.foo']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   178
        self.assertEquals(container.get_refs(), ["dummy1.too",
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   179
                                                 "dummy2.foo",])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   180
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   181
    def test_impl_container_list_output_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   182
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   183
        subcontainer = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
        subcontainer.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   190
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   191
        self.assertEquals(container.list_output_files(), [])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   192
        imp2b.output_files= ['output/dummy2.txt']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   193
        self.assertEquals(container.list_output_files(), ['output/dummy2.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   194
        imp1.output_files= ['output/foobar/hee.txt']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   195
        self.assertEquals(container.list_output_files(), ['output/foobar/hee.txt',
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   196
                                                          'output/dummy2.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   198
    def test_impl_container_set_output_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   199
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   200
        subcontainer = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   201
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   202
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   203
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   204
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   205
        subcontainer.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   206
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   207
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   208
        self.assertEquals(imp1.get_output_root(), 'output')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   209
        container.set_output_root('foobar/test')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   210
        self.assertEquals(imp1.get_output_root(), 'foobar/test')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   211
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   212
    def test_impl_container_sub_container_generate(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   216
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   217
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   218
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   219
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   221
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   223
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   224
        container.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   225
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   227
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   228
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   229
    def test_impl_container_sub_container_generate_with_generation_contexts(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   230
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   231
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   232
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   233
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   234
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   235
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   236
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   237
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   238
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   239
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   240
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   241
        context.objects = []
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   242
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   243
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   244
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   245
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   246
        self.assertEquals(len(context.objects), 3)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   247
        self.assertEquals(context.objects, [imp1,imp2a,imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   248
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   249
    def test_impl_container_generate_with_generation_contexts_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   250
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   251
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   252
        subcontainer1 = plugin.ImplContainer("implml/sub1.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   253
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   254
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   255
        subcontainer2 = plugin.ImplContainer("implml/sub2.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   256
        subcontainer2.set_tags({'target': ['rofs3','uda']})
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   257
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   258
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   259
        subcontainer2.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   260
        subcontainer2.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   261
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   262
        container.append(subcontainer2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   263
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   264
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   265
        context.tags = {'target': ['rofs3'], 'foobar' :['test']}
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   266
        context.objects = []
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   267
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   268
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   269
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   270
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   271
        self.assertEquals(len(context.objects), 2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   272
        self.assertEquals(context.objects, [imp2a,imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   273
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   274
    def test_impl_container_generate_with_generation_phase(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   275
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   276
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   277
        subcontainer1 = plugin.ImplContainer("implml/sub1.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   278
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   279
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   280
        subcontainer2 = plugin.ImplContainer("implml/sub2.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   281
        subcontainer2.set_invocation_phase("post")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   282
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   283
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   284
        subcontainer2.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   285
        subcontainer2.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   286
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   287
        container.append(subcontainer2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   288
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   289
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   290
        context.phase = "post"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   291
        context.objects = []
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   292
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   293
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   294
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   295
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   296
        self.assertEquals(len(context.objects), 2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   297
        self.assertEquals(context.objects, [imp2a,imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   298