Bug 1088060 - [mozversion] Get all application and platform data. r=dhunt

---
 testing/mozbase/mozversion/mozversion/mozversion.py | 10 +++++-----
 testing/mozbase/mozversion/tests/test_binary.py     | 11 +++++++++--
 2 files changed, 14 insertions(+), 7 deletions(-)

--HG--
extra : rebase_source : 85ab0046a4aa8c96dc32e7ff24f7cfeeee2f034b
This commit is contained in:
Henrik Skupin 2014-10-23 17:46:23 +02:00
parent d6f20f3df0
commit 066f50cd0c
2 changed files with 14 additions and 7 deletions

View File

@ -42,11 +42,11 @@ class Version(object):
def _parse_ini_file(self, fp, type, section):
config = ConfigParser.RawConfigParser()
config.readfp(fp)
name_map = {'CodeName': 'display_name',
'SourceRepository': 'repository',
'SourceStamp': 'changeset'}
for key in ('BuildID', 'Name', 'CodeName', 'Version',
'SourceRepository', 'SourceStamp'):
name_map = {'codename': 'display_name',
'milestone': 'version',
'sourcerepository': 'repository',
'sourcestamp': 'changeset'}
for key, value in config.items(section):
name = name_map.get(key, key).lower()
self._info['%s_%s' % (type, name)] = config.has_option(
section, key) and config.get(section, key) or None

View File

@ -17,15 +17,18 @@ class BinaryTest(unittest.TestCase):
"""test getting application version information from a binary path"""
application_ini = """[App]
ID = AppID
Name = AppName
CodeName = AppCodeName
Version = AppVersion
BuildID = AppBuildID
SourceRepository = AppSourceRepo
SourceStamp = AppSourceStamp
Vendor = AppVendor
"""
platform_ini = """[Build]
BuildID = PlatformBuildID
Milestone = PlatformMilestone
SourceStamp = PlatformSourceStamp
SourceRepository = PlatformSourceRepo
"""
@ -114,22 +117,26 @@ SourceRepository = PlatformSourceRepo
f.writelines(self.platform_ini)
def _check_version(self, version):
self.assertEqual(version.get('application_id'), 'AppID')
self.assertEqual(version.get('application_name'), 'AppName')
self.assertEqual(version.get('application_display_name'), 'AppCodeName')
self.assertEqual(
version.get('application_display_name'), 'AppCodeName')
self.assertEqual(version.get('application_version'), 'AppVersion')
self.assertEqual(version.get('application_buildid'), 'AppBuildID')
self.assertEqual(
version.get('application_repository'), 'AppSourceRepo')
self.assertEqual(
version.get('application_changeset'), 'AppSourceStamp')
self.assertEqual(version.get('application_vendor'), 'AppVendor')
self.assertIsNone(version.get('platform_name'))
self.assertIsNone(version.get('platform_version'))
self.assertEqual(version.get('platform_buildid'), 'PlatformBuildID')
self.assertEqual(
version.get('platform_repository'), 'PlatformSourceRepo')
self.assertEqual(
version.get('platform_changeset'), 'PlatformSourceStamp')
self.assertIsNone(version.get('invalid_key'))
self.assertEqual(
version.get('platform_version'), 'PlatformMilestone')
if __name__ == '__main__':