def testGetUpgradeCode(self):
        def mockBuildMSI(version, upCode=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 = 'FIXME'
                upgradeCode = a._getUpgradeCode()
                if not upgradeCode:
                    upgradeCode = 'None'
                if upCode:
                    upgradeCode = upCode
                a.recipe.winHelper.upgradeCode = upgradeCode

            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', '12345')
        built = self.cookItem(repos, self.cfg, 'WindowsAppTest')

        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')
        built = self.cookItem(repos, self.cfg, 'WindowsAppTest')[0]

        msis = [ x for x in built if x[0].endswith(':msi') ]
        self.assertEqual(len(msis), 1)

        msi = msis[0]

        repos = self.openRepository()
        spec = repos.findTrove(self.cfg.buildLabel, msi)
        self.assertEqual(len(spec), 1)

        trv = repos.getTrove(*spec[0])

        self.assertEqual(trv.troveInfo.capsule.msi.name(), 'WindowsAppTest')
        self.assertEqual(trv.troveInfo.capsule.msi.platform(), '')
        self.assertEqual(trv.troveInfo.capsule.msi.version(), '1.2.3.5')
        self.assertEqual(trv.troveInfo.capsule.msi.productCode(), 'FIXME')
        self.assertEqual(trv.troveInfo.capsule.msi.upgradeCode(), '12345')
dataset/ETHPy150Open sassoftware/conary/conary_test/cvctest/buildtest/windowsactiontest.py/WindowsActionTest.testGetUpgradeCode/original