def testOnePlatform(self): with mock.patch.dict(ftp_update_platform_map, {'p': ['pp']}): expected = ['foo/1/pp/2/aa/c/complete.txt'] got = getSnippetPaths( product='foo', version='1', platform='p', buildid=2, locale='aa', channel='c', type_='complete') self.assertEquals(got, expected)
def testMultiplePlatforms(self): with mock.patch.dict(ftp_update_platform_map, {'p': ['pp1', 'pp2']}): expected = ['foo/1/pp1/2/bb/c/partial.txt', 'foo/1/pp2/2/bb/c/partial.txt'] got = getSnippetPaths( product='foo', version='1', platform='p', buildid=2, locale='bb', channel='c', type_='partial') self.assertEquals(got, expected)
def testOnePlatform(self): with mock.patch.dict(ftp_update_platform_map, {'p': ['pp']}): expected = ['foo/1/pp/2/aa/c/complete.txt'] got = getSnippetPaths(product='foo', version='1', platform='p', buildid=2, locale='aa', channel='c', type_='complete') self.assertEquals(got, expected)
def testMultiplePlatforms(self): with mock.patch.dict(ftp_update_platform_map, {'p': ['pp1', 'pp2']}): expected = [ 'foo/1/pp1/2/bb/c/partial.txt', 'foo/1/pp2/2/bb/c/partial.txt' ] got = getSnippetPaths(product='foo', version='1', platform='p', buildid=2, locale='bb', channel='c', type_='partial') self.assertEquals(got, expected)
info = getChecksum(platform, locale, checksumsFile) # We may have multiple update types to generate a snippet for... for type_ in updateTypes: # And also multiple channels... for channel in channels: log.debug("Processing: %s %s %s %s %s" % ( fromVersion, platform, locale, channel, type_)) url = pc.getUrl(fromVersion, platform, locale, type_, channel) filename = path.basename( pc.getPath(fromVersion, platform, locale, type_)) for f in info: if filename == path.basename(f): hash_ = info[f]['hashes'][hashType] size = info[f]['size'] break else: raise Exception("Couldn't find hash/size, bailing") # We also may have multiple snippets for the same platform. for snippet in getSnippetPaths(pc['appName'], fromAppVersion, platform, fromBuildid, locale, channel, type_): if channel in pc['current-update']['channel']: snippet = path.join(options.snippet_dir, snippet) else: snippet = path.join(options.test_snippet_dir, snippet) contents = createSnippet(fromRelease['schema'], type_, url, hash_, size, buildid, prettyVersion, appVersion, detailsUrl, hashType, **optionalAttrs) log.info("Writing snippet: %s" % snippet) if not path.exists(path.dirname(snippet)): makedirs(path.dirname(snippet)) with open(snippet, 'w') as f: f.write(contents)