configurationengine/source/cone/public/tests/unittest_plugin_implcontainer.py
author m2lahtel
Tue, 10 Aug 2010 14:29:28 +0300
changeset 3 e7e0ae78773e
parent 0 2e8eeb919028
permissions -rw-r--r--
ConE 1.2.11 release
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     1
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     3
# All rights reserved.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     4
# This component and the accompanying materials are made available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     6
# which accompanies this distribution, and is available
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     8
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     9
# Initial Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    11
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    12
# Contributors:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    13
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    14
# Description:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    15
#
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    16
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
import unittest
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
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    20
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    21
from cone.public import api, plugin, rules
0
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
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    31
            self.output_created = False
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
            self.refs = ["dummy1.too"]
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    33
            self.output_files = ['foo/test.txt']
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    34
            self.context = None
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
        def generate(self, context=None):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
            self.generate_invoked = True
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    37
            if context:
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    38
                for outfile in self.list_output_files():
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    39
                    context.add_file(outfile, implementation=self)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    40
            
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
        def get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
            return self.refs
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
        def list_output_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
            return self.output_files
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    47
        def get_outputs(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    48
            """
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    49
            Return a list of GenerationOutput objets as a list. 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    50
            """
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    51
            outputs = []
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    52
            phase = None 
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    53
            if self.context: phase = self.context.phase
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    54
            for outfile in self.list_output_files():
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    55
                outputs.append( plugin.GenerationOutput(outfile,self,type='file', phase=phase) )
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    56
            return outputs
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    57
    
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
    def test_impl_container_add(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
        imp1  = plugin.ImplBase("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
        imp2a = plugin.ImplBase("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
        imp2b = plugin.ImplBase("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
        self.assertEquals(container.impls, [imp1,imp2a, imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
    def test_impl_container_sub_container(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
        imp1  = plugin.ImplBase("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
        imp2a = plugin.ImplBase("implml/sub.implml:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
        imp2b = plugin.ImplBase("implml/sub.implml:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    77
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    78
        self.assertEquals(container.get_all_implementations(),[imp1,imp2a,imp2b])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    79
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    80
        container[0] = subcontainer
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    81
        self.assertEquals(container.impls, [subcontainer,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    82
        del container[0]
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    83
        self.assertEquals(container.impls, [subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    84
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    85
    def test_impl_container_with_condition(self):
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    86
        logger = logging.getLogger('cone')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    87
        ch = logging.StreamHandler()
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    88
        ch.setLevel(logging.DEBUG)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
    89
        logger.addHandler(ch)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    90
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    91
        context.configuration = api.Configuration()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    92
        context.configuration.add_feature(api.Feature("test"))
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    93
        context.configuration.add_feature(api.Feature("stringsub"),"test")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    94
        context.configuration.add_feature(api.Feature("intsub"),"test")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    95
        context.configuration.get_default_view().test.value = True
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    96
        context.configuration.get_default_view().test.stringsub.value = "stringval"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    97
        context.configuration.get_default_view().test.intsub.value = 2
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    98
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    99
        condition = rules.SimpleCondition("${test}", "true")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   100
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   101
        container.condition = condition
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   102
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   103
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   104
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   105
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   106
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   107
        context.configuration.get_default_view().test.value = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   108
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   109
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   110
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   111
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   112
        condition = rules.SimpleCondition("${test}", "false")
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   113
        container.condition = condition
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   114
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   115
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   116
        imp1.generate_invoked = False
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   117
        context.configuration.get_default_view().test.value = True
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   118
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   119
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   120
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   121
        imp1.generate_invoked = False
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   122
        condition = rules.SimpleCondition("${test.intsub}", "1")
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   123
        container.condition = condition
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   124
        container.append(imp1)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   125
        container.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   126
        self.assertFalse(imp1.generate_invoked)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   127
        context.configuration.get_default_view().test.intsub.value = 1
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   128
        container.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   129
        self.assertTrue(imp1.generate_invoked)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   130
        
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   131
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   132
    def test_impl_container_generate(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   133
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   134
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   135
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   136
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   137
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   138
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   139
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   140
        container.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   141
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   142
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   143
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   144
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   145
    def test_impl_container_get_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   146
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   147
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   148
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   149
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   150
        subcontainer = plugin.ImplContainer("sub", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   151
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   152
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   153
        container.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   154
        container.append(subcontainer)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   155
        self.assertEquals(container.get_tags(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   156
        self.assertEquals(container.get_child_tags(), {})
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   157
        container.set_tags({'test':['foobar']})
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   158
        self.assertEquals(container.get_tags(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   159
        self.assertEquals(container.get_child_tags(), {})
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   160
        imp1.set_tags({'foo':['bar']})
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   161
        self.assertEquals(container.get_child_tags(), {'foo':['bar']})
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   162
        self.assertEquals(container.get_tags(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   163
        imp2a.set_tags({'test':['bar'], 'foo' :['more']})
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   164
        self.assertEquals(container.get_child_tags(), {'foo':['bar', 'more'], 'test': ['bar']})
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   165
        
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   166
        self.assertEquals(container.get_tags(), None)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   167
        subcontainer.set_tags({'test':['bar1']})
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   168
        self.assertEquals(container.get_tags(), None)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   169
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   170
    def test_impl_container_get_phase(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   171
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   172
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   173
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   174
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   175
        subcontainer1 = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   176
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   177
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   178
        subcontainer1.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   179
        subcontainer1.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   180
        subcontainer1.set_invocation_phase("normal")
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   181
        self.assertEquals(container.invocation_phase(), "normal")
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   182
        imp1.set_invocation_phase('pre')
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   183
        self.assertEquals(container.invocation_phase(), "normal")
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   184
        subcontainer2 = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   185
        subimp = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   186
        subimp.set_invocation_phase('post')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   187
        subcontainer2.append(subimp)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   188
        subcontainer2.set_invocation_phase('post')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   189
        container.append(subcontainer2)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   190
        self.assertEquals(container.invocation_phase(), 'normal')
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_impl_container_get_refs(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   193
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   194
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   195
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   196
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   197
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   198
        container.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   199
        container.append(imp2b)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   200
        self.assertEquals(container.get_refs(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   201
        self.assertEquals(container.get_child_refs(), ['dummy1.too'])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   202
        imp2b.refs = ['dummy2.foo']
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   203
        self.assertEquals(container.get_refs(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   204
        self.assertEquals(container.get_child_refs(), ['dummy1.too', 'dummy2.foo'])
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   205
        imp2b.refs = None
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   206
        self.assertEquals(container.get_refs(), None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   207
        self.assertEquals(container.get_child_refs(), ['dummy1.too'])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   208
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   209
    def test_impl_container_list_output_files(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   210
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   211
        subcontainer = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   212
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   213
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   214
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   215
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   216
        subcontainer.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   217
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   218
        subcontainer.append(imp2b)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   219
        self.assertEquals(container.list_output_files(), ['foo/test.txt'])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   220
        imp2b.output_files= ['output/dummy2.txt']
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   221
        self.assertEquals(container.list_output_files(), ['foo/test.txt', 'output/dummy2.txt'])
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   222
        imp1.output_files= ['output/foobar/hee.txt']
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   223
        self.assertEquals(container.list_output_files(), ['output/foobar/hee.txt',
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   224
                                                          'foo/test.txt', 
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   225
                                                          'output/dummy2.txt'])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   226
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   227
    def test_impl_container_get_outputs(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   228
        container = plugin.ImplContainer("norm", None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   229
        subcontainer = plugin.ImplContainer("norm", None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   230
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   231
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   232
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   233
        container.append(subcontainer)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   234
        subcontainer.append(imp1)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   235
        subcontainer.append(imp2a)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   236
        subcontainer.append(imp2b)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   237
        self.assertEquals(len(container.get_outputs()), 3)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   238
        self.assertEquals(container.get_outputs()[0].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   239
        self.assertEquals(container.get_outputs()[1].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   240
        self.assertEquals(container.get_outputs()[2].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   241
        imp2b.output_files= ['foobar.txt','output/dummy2.txt']
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   242
        self.assertEquals(len(container.get_outputs()),4)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   243
        self.assertEquals(container.get_outputs()[0].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   244
        self.assertEquals(container.get_outputs()[1].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   245
        self.assertEquals(container.get_outputs()[2].name, 'foobar.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   246
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   247
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   248
    def test_impl_container_set_output_root(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   249
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   250
        subcontainer = 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
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   253
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   254
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   255
        subcontainer.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   256
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   257
        subcontainer.append(imp2b)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   258
        self.assertEquals(imp1.get_output_root(), '')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   259
        container.set_output_root('foobar/test')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   260
        self.assertEquals(imp1.get_output_root(), 'foobar/test')
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   261
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   262
    def test_impl_container_sub_container_generate(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   263
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   264
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   265
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   266
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   267
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   268
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   269
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   270
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   271
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   272
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   273
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   274
        container.generate()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   275
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   276
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   277
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   278
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   279
    def test_impl_container_sub_container_generate_with_generation_contexts(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   280
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   281
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   282
        container.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   283
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   284
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   285
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   286
        subcontainer.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   287
        subcontainer.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   288
        container.append(subcontainer)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   289
        self.assertEquals(container.impls, [imp1,subcontainer])
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   290
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   291
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   292
        self.assertTrue(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   293
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   294
        self.assertTrue(imp2a.generate_invoked)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   295
        self.assertEquals(sorted(context.executed_impls), sorted([imp1,imp2a,imp2b]))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   296
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   297
    def test_impl_container_generate_with_generation_contexts_tags(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   298
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   299
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   300
        subcontainer1 = plugin.ImplContainer("implml/sub1.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   301
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   302
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   303
        subcontainer2 = plugin.ImplContainer("implml/sub2.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   304
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   305
        imp2a.set_tags({'target': ['rofs3','uda']})
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   306
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   307
        imp2b.set_tags({'target': ['rofs3','uda']})
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   308
        subcontainer2.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   309
        subcontainer2.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   310
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   311
        container.append(subcontainer2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   312
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   313
        context = plugin.GenerationContext()
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   314
        context.tags = {'target': ['rofs3'], 'foobar' :['test']}
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   315
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   316
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   317
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   318
        self.assertTrue(imp2a.generate_invoked)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   319
        self.assertEquals(sorted(context.executed_impls), sorted([imp2a,imp2b]))
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   320
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   321
    def test_impl_container_generate_with_generation_phase(self):
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   322
        container = plugin.ImplContainer("norm", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   323
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   324
        subcontainer1 = plugin.ImplContainer("implml/sub1.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   325
        subcontainer1.append(imp1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   326
        
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   327
        subcontainer2 = plugin.ImplContainer("implml/sub2.implml", None)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   328
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   329
        imp2a.set_invocation_phase("post")
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   330
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   331
        imp2b.set_invocation_phase("post")
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   332
        subcontainer2.append(imp2a)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   333
        subcontainer2.append(imp2b)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   334
        container.append(subcontainer1)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   335
        container.append(subcontainer2)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   336
        
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   337
        context = plugin.GenerationContext(output='')
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   338
        context.phase = "post"
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   339
        container.generate(context)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   340
        self.assertFalse(imp1.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   341
        self.assertTrue(imp2a.generate_invoked)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   342
        self.assertTrue(imp2a.generate_invoked)
3
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   343
        self.assertEquals(sorted(context.executed_impls), sorted([imp2a,imp2b]))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   344
        self.assertEquals(context.executed_impls[0].list_output_files(), ['foo/test.txt'])
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   345
        self.assertEquals(len(context.generation_output), 2)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   346
        self.assertEquals(context.generation_output[0].name, 'foo/test.txt')
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   347
        self.assertEquals(str(context.generation_output[0]), "GenerationOutput(foo/test.txt, ImplTest(ref='implml/copy:21.content', type=None, lineno=None))")
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   348
        self.assertEquals(str(context.generation_output[1]), "GenerationOutput(foo/test.txt, ImplTest(ref='implml/copy:24.content', type=None, lineno=None))")
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   349
        self.assertEquals(context.generation_output[0].implementation, imp2a)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   350
        
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   351
    def test_impl_container_generate_dry_run(self):
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   352
        container = plugin.ImplContainer("norm", None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   353
        imp1  = TestPluginImplContainer.ImplTest("implml/test.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   354
        container.append(imp1)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   355
        subcontainer = plugin.ImplContainer("implml/sub.implml", None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   356
        imp2a = TestPluginImplContainer.ImplTest("implml/copy:21.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   357
        imp2b = TestPluginImplContainer.ImplTest("implml/copy:24.content",None)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   358
        subcontainer.append(imp2a)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   359
        subcontainer.append(imp2b)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   360
        container.append(subcontainer)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   361
        self.assertEquals(container.impls, [imp1,subcontainer])
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   362
        context = plugin.GenerationContext()
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   363
        context.dry_run= True
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   364
        container.generate(context)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   365
        self.assertFalse(imp1.generate_invoked)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   366
        self.assertFalse(imp2a.generate_invoked)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   367
        self.assertFalse(imp2a.generate_invoked)
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   368
        self.assertEquals(sorted(context.executed_impls), sorted([imp1, imp2a,imp2b]))
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   369
        self.assertEquals(context.executed_impls[0].list_output_files(), ['foo/test.txt'])
e7e0ae78773e ConE 1.2.11 release
m2lahtel
parents: 0
diff changeset
   370
        self.assertEquals(len(context.generation_output), 0)
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
   371