def getSubModConfigList(modList): subModconfigList = [] for mod in modList: for submod in mod['submods']: conf = installConfiguration.SubModConfig(mod, submod) logger.printNoTerminal(conf) subModconfigList.append(conf) return subModconfigList
def test_highLevelFunctions(self): remoteSubModVersionJSONString = """ { "id" : "Onikakushi Ch.1/full", "files":[ {"id": "cg", "version": "1.0.0"}, {"id": "cgalt", "version": "1.0.0"}, {"id": "movie", "version": "1.0.0"}, {"id": "voices", "version": "1.0.0"}, {"id": "script", "version": "6.1.0"}, {"id": "movie-unix", "version": "1.0.0"}, {"id": "ui-windows", "version": "1.0.0"}, {"id": "ui-unix", "version": "1.0.0"} ] } """ remoteVersionObject = fileVersionManagement.SubModVersionInfo( json.loads(remoteSubModVersionJSONString)) test_dir = tempfile.mkdtemp() modList = self.getModListFromDummyJSON() mod = modList[0] submod = mod['submods'][0] subModConfig = installConfiguration.SubModConfig(mod, submod) fullConfig = installConfiguration.FullInstallConfiguration( subModConfig, test_dir, True) originalModFileList = fullConfig.buildFileListSorted('datadir') # If there is no file present, all files should require download fileVersionManager = fileVersionManagement.VersionManager( subMod=subModConfig, modFileList=originalModFileList, localVersionFolder=test_dir, _testRemoteSubModVersion=remoteVersionObject) self.assertEqual(fileVersionManager.getFilesRequiringUpdate(), originalModFileList) self.assertEqual(fileVersionManager.fullUpdateRequired(), True) fileVersionManager.saveVersionInstallFinished() # If there is a file present which is identical, no files should require download fileVersionManagerIdentical = fileVersionManagement.VersionManager( subMod=subModConfig, modFileList=originalModFileList, localVersionFolder=test_dir, _testRemoteSubModVersion=remoteVersionObject) self.assertEqual(fileVersionManagerIdentical.getFilesRequiringUpdate(), []) self.assertEqual(fileVersionManagerIdentical.fullUpdateRequired(), False) shutil.rmtree(test_dir)
def pre_build_validation(): import installConfiguration import common import fileVersionManagement print("Travis validation started") # Code is modified version of main.getSubModConfigList since I don't want to import/setup logger.py sub_mod_configs = [] for mod in common.getModList("installData.json", isURL=False): for submod in mod['submods']: conf = installConfiguration.SubModConfig(mod, submod) sub_mod_configs.append(conf) fileVersionManagement.Developer_ValidateVersionDataJSON(sub_mod_configs) print("Travis validation success")
def getAllURLsFromModList(modList, shouldPrint=False): # type: (typing.Any, typing.Optional[bool]) -> typing.List[str] """ This function parses the modList (from common.getModList()), and returns all downloadable URLs contained in it. Metalinks are treated as just "one" URL, even if they contain multiple files inside. :param modList: JSON modList object from common.getModList() :param shouldPrint: Enables/Disables debug printing :return: a list of URLs (str) from the modList JSON object """ if shouldPrint: customPrint = print else: def customPrint(*args, **kwargs): pass subModconfigList = [] for mod in modList: for submod in mod['submods']: conf = installConfiguration.SubModConfig(mod, submod) subModconfigList.append(conf) # Extract all URLs from the JSON file allURLsSet = OrderedDict() for submod in subModconfigList: customPrint(submod) customPrint("files:") for file in submod.files: customPrint(file.url) allURLsSet[file.url] = None customPrint("overrides:") for fileOverride in submod.fileOverrides: customPrint(fileOverride.url) allURLsSet[fileOverride.url] = None for option in submod.modOptions: if option.type == 'downloadAndExtract': if option.data is not None: customPrint(option.data['url']) allURLsSet[option.data['url']] = None customPrint("\n\n") return [x for x in allURLsSet.keys() if x is not None]
def test_filterFileListInner(self): modList = self.getModListFromDummyJSON() mod = modList[0] submod = mod['submods'][0] subModConfig = installConfiguration.SubModConfig(mod, submod) fullConfig = installConfiguration.FullInstallConfiguration(subModConfig, '.', True) fileList = fullConfig.buildFileListSorted('datadir') # Test if versions have not changed unchangedTestSet = (json.loads(""" { "id" : "Onikakushi Ch.1/full", "lastAttemptedInstallID" : "Onikakushi Ch.1/full", "files":[ {"id": "cg", "version": "1.0.0"}, {"id": "cgalt", "version": "1.0.0"}, {"id": "movie", "version": "1.0.0"}, {"id": "voices", "version": "1.0.0"}, {"id": "script", "version": "6.1.0"}, {"id": "ui-windows", "version": "2.1.0"} ] } """), json.loads(""" { "id" : "Onikakushi Ch.1/full", "lastAttemptedInstallID" : "Onikakushi Ch.1/full", "files":[ {"id": "cg", "version": "1.0.0"}, {"id": "cgalt", "version": "1.0.0"}, {"id": "movie", "version": "1.0.0"}, {"id": "voices", "version": "1.0.0"}, {"id": "script", "version": "6.1.0"}, {"id": "ui-windows", "version": "2.1.0"} ] } """)) updateInformation = fileVersionManagement.getFilesNeedingUpdate(fileList, fileVersionManagement.SubModVersionInfo(unchangedTestSet[0]), fileVersionManagement.SubModVersionInfo(unchangedTestSet[1])) result = convertUpdateInformationToModFileList(fileList, updateInformation) self.assertEqual(result, []) print("Unchanged", [x.id for x in result]) # Test if 'cg' version changes, that both 'cg' and 'script' need update dependencyTestSet = (json.loads(""" { "id" : "Onikakushi Ch.1/full", "lastAttemptedInstallID" : "Onikakushi Ch.1/full", "files":[ {"id": "cg", "version": "1.0.0"}, {"id": "cgalt", "version": "1.0.0"}, {"id": "movie", "version": "1.0.0"}, {"id": "voices", "version": "1.0.0"}, {"id": "script", "version": "6.1.0"}, {"id": "ui-windows", "version": "2.1.0"} ] } """), json.loads(""" { "id" : "Onikakushi Ch.1/full", "lastAttemptedInstallID" : "Onikakushi Ch.1/full", "files":[ {"id": "cg", "version": "1.0.1"}, {"id": "cgalt", "version": "1.0.0"}, {"id": "movie", "version": "1.0.0"}, {"id": "voices", "version": "1.0.0"}, {"id": "script", "version": "6.1.0"}, {"id": "ui-windows", "version": "2.1.0"} ] } """)) updateInformation = fileVersionManagement.getFilesNeedingUpdate(fileList, fileVersionManagement.SubModVersionInfo(dependencyTestSet[0]), fileVersionManagement.SubModVersionInfo(dependencyTestSet[1])) result = convertUpdateInformationToModFileList(fileList, updateInformation) idSet = set(x.id for x in result) self.assertIn('cg', idSet) #cg changed version self.assertIn('script', idSet) #script is a dependency of cg (must overwrite cg) idSet.remove('cg') idSet.remove('script') self.assertEqual(idSet, set()) #no other items should remain in the list