def testPersistingComponentInformation(self):
        def mockBuildMSI(version, components=None):
            def do(a, macros):
                a.package = a.package % macros
                msiPath = os.path.join(self.archivePath, 'Setup2.msi')
                a.recipe._addCapsule(msiPath, 'msi', a.package % macros)
                a.recipe.winHelper = source.WindowsHelper()
                a.recipe.winHelper.productName = 'WindowsAppTest'
                a.recipe.winHelper.platform = ''
                a.recipe.winHelper.version = version
                a.recipe.winHelper.productCode = 'foo'
                a.recipe.winHelper.upgradeCode = 'bar'
                if components:
                    a.recipe.winHelper.components = components
                for comp in a._getComponentInfo():
                    if comp not in a.recipe.winHelper.components:
                        a.recipe.winHelper.components.append(comp)

            self.mock(build.BuildMSI, 'do', do)

        repos = self.openRepository()
        origDir = os.getcwd()

        self.resetWork()
        os.chdir(self.workDir)

        self.newpkg('WindowsAppTest')
        os.chdir('WindowsAppTest')
        self.writeFile('WindowsAppTest.recipe', self.test_recipe1)
        self.addfile('WindowsAppTest.recipe')
        self.commit()

        os.chdir(origDir)
        self.resetWork()
        os.chdir(self.workDir)

        mockBuildMSI('1.2.3.4',
            components=[('uuid1', 'path1'), ('uuid2', 'path2')])

        built = self.cookItem(repos, self.cfg, 'WindowsAppTest')

        spec = repos.findTrove(self.cfg.buildLabel,
            ('WindowsAppTest:msi', None, None))[0]
        trv = repos.getTrove(*spec)

        components = [ (x.uuid(), x.path())
            for _, x in trv.troveInfo.capsule.msi.components.iterAll() ]

        self.assertTrue(('uuid1', 'path1') in components)
        self.assertTrue(('uuid2', 'path2') in components)

        self.checkout('WindowsAppTest')
        os.chdir('WindowsAppTest')
        self.writeFile('WindowsAppTest.recipe',
            self.test_recipe1.replace('1.2.3.4', '1.2.3.5'))
        self.commit()

        self.resetWork()
        os.chdir(origDir)

        mockBuildMSI('1.2.3.5', components=[('uuid3', 'path3'), ])
        built = self.cookItem(repos, self.cfg, 'WindowsAppTest')

        spec = repos.findTrove(self.cfg.buildLabel,
            ('WindowsAppTest:msi', None, None))[0]
        trv = repos.getTrove(*spec)

        components = [ (x.uuid(), x.path())
            for _, x in trv.troveInfo.capsule.msi.components.iterAll() ]

        self.assertTrue(('uuid1', 'path1') in components)
        self.assertTrue(('uuid2', 'path2') in components)
        self.assertTrue(('uuid3', 'path3') in components)
dataset/ETHPy150Open sassoftware/conary/conary_test/cvctest/buildtest/windowsactiontest.py/WindowsActionTest.testPersistingComponentInformation/original