Skip to content

Commit

Permalink
Merge pull request #54 from nurav/master
Browse files Browse the repository at this point in the history
Bug 1113111 - tracebacks when a platform exists in a blob but has no locales. r=bhearsum
  • Loading branch information
Ben Hearsum committed Mar 1, 2016
2 parents 10629fa + 937acd5 commit ce2b447
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion auslib/blobs/apprelease.py
Expand Up @@ -58,11 +58,16 @@ def getLocaleOrTopLevelParam(self, platform, locale, param):

def getBuildID(self, platform, locale):
platform = self.getResolvedPlatform(platform)
if locale not in self['platforms'][platform]['locales']:
if locale not in self['platforms'].get(platform, {}) \
.get('locales', {}):
raise BadDataError("No such locale '%s' in platform '%s'" % (locale, platform))
try:
return self['platforms'][platform]['locales'][locale]['buildID']
except KeyError:
if platform not in self['platforms']:
raise BadDataError("No such platform '%s'" % (platform))
if 'buildID' not in self['platforms'][platform].keys():
raise BadDataError("No buildID for platform '%s'" % (platform))
return self['platforms'][platform]['buildID']

def _getFromRelease(self, patch):
Expand Down
16 changes: 16 additions & 0 deletions auslib/test/blobs/test_apprelease.py
Expand Up @@ -73,6 +73,22 @@ def testGetBuildIDMissingLocale(self):
blob = SimpleBlob(platforms=dict(c=dict(locales=dict(d=dict(buildID=9)))))
self.assertRaises(BadDataError, blob.getBuildID, 'c', 'a')

def testGetBuildIDMissingPlatform(self):
blob = SimpleBlob(platforms=dict())
self.assertRaises(BadDataError, blob.getBuildID, 'c', 'a')

def testGetBuildIDMissingLocalesFieldInPlatform(self):
blob = SimpleBlob(platforms=dict(c=dict()))
self.assertRaises(BadDataError, blob.getBuildID, 'c', 'a')

def testGetBuildIDMissingPlatformWithNoLocale(self):
blob = SimpleBlob(platforms=dict())
self.assertRaises(BadDataError, blob.getBuildID, 'c', None)

def testGetBuildIDMissingBuildIDAtPlatformAndLocale(self):
blob = SimpleBlob(platforms=dict(c=dict(locales=dict(d=dict()))))
self.assertRaises(BadDataError, blob.getBuildID, 'c', 'a')

def testGetBuildIDMissingLocaleBuildIDAtPlatform(self):
blob = SimpleBlob(platforms=dict(c=dict(buildID=9, locales=dict(d=dict()))))
self.assertRaises(BadDataError, blob.getBuildID, 'c', 'a')
Expand Down

1 comment on commit ce2b447

@TaskClusterRobot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.