def testSchema2OptionalAttribute(self): expected = """\ version=2 type=complete url=http://foo hashFunction=SHA512 hashValue=xxxxx size=123 build=789 displayVersion=1 Beta 1 appVersion=1 platformVersion=1 detailsUrl=http://details actions=silent billboardURL=http://billboard\n""" got = createSnippet(schema=2, type_='complete', url='http://foo', hash_='xxxxx', size=123, buildid=789, displayVersion='1 Beta 1', appVersion=1, detailsUrl='http://details', actions=['silent'], billboardURL='http://billboard') self.assertEquals(got, expected)
def testSchema1(self): expected = """\ version=1 type=partial url=http://bar hashFunction=SHA512 hashValue=aaaaa size=5 build=6 appv=4 extv=2 detailsUrl=http://details\n""" got = createSnippet( schema=1, type_='partial', url='http://bar', hash_='aaaaa', size=5, buildid=6, displayVersion='4', appVersion='2', detailsUrl='http://details') self.assertEquals(got, expected)
def testDifferentHashFunction(self): expected = """\ version=2 type=complete url=http://foo hashFunction=SHA1024 hashValue=yyyyy size=123 build=789 displayVersion=1 Beta 1 appVersion=1 platformVersion=1 detailsUrl=http://details\n""" got = createSnippet( schema=2, type_='complete', url='http://foo', hash_='yyyyy', size=123, buildid=789, displayVersion='1 Beta 1', appVersion=1, detailsUrl='http://details', hashFunction='SHA1024') self.assertEquals(got, expected)
def testSchema2OptionalAttribute(self): expected = """\ version=2 type=complete url=http://foo hashFunction=SHA512 hashValue=xxxxx size=123 build=789 displayVersion=1 Beta 1 appVersion=1 platformVersion=1 detailsUrl=http://details actions=silent billboardURL=http://billboard\n""" got = createSnippet( schema=2, type_='complete', url='http://foo', hash_='xxxxx', size=123, buildid=789, displayVersion='1 Beta 1', appVersion=1, detailsUrl='http://details', actions=['silent'], billboardURL='http://billboard') self.assertEquals(got, expected)
def testSchema1(self): expected = """\ version=1 type=partial url=http://bar hashFunction=SHA512 hashValue=aaaaa size=5 build=6 appv=4 extv=2 detailsUrl=http://details\n""" got = createSnippet(schema=1, type_='partial', url='http://bar', hash_='aaaaa', size=5, buildid=6, displayVersion='4', appVersion='2', detailsUrl='http://details') self.assertEquals(got, expected)
def testSchema2(self): expected = """\ version=2 type=complete url=http://foo hashFunction=SHA512 hashValue=xxxxx size=123 build=789 displayVersion=1 Beta 1 appVersion=1 platformVersion=1 detailsUrl=http://details\n""" got = createSnippet(schema=2, type_='complete', url='http://foo', hash_='xxxxx', size=123, buildid=789, displayVersion='1 Beta 1', appVersion=1, detailsUrl='http://details') 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)