Bug 1261101 - Add full update snippet contents to the update results dictionary. r?maja_zf
MozReview-Commit-ID: sgeTaYlu8P
--- a/testing/firefox-ui/tests/puppeteer/manifest.ini
+++ b/testing/firefox-ui/tests/puppeteer/manifest.ini
@@ -3,16 +3,17 @@ tags = local
# API tests
[test_l10n.py]
[test_places.py]
[test_prefs.py]
[test_security.py]
tags = remote
[test_software_update.py]
+tags = remote
[test_utils.py]
# UI tests
[test_about_window.py]
[test_menubar.py]
[test_notifications.py]
[test_page_info_window.py]
[test_tabbar.py]
--- a/testing/firefox-ui/tests/puppeteer/test_software_update.py
+++ b/testing/firefox-ui/tests/puppeteer/test_software_update.py
@@ -33,17 +33,18 @@ class TestSoftwareUpdate(FirefoxTestCase
def test_build_info(self):
build_info = self.software_update.build_info
self.assertEqual(build_info['disabled_addons'], None)
self.assertIn('Mozilla/', build_info['user_agent'])
self.assertEqual(build_info['mar_channels'], set(['expected', 'channels']))
self.assertTrue(build_info['version'])
self.assertTrue(build_info['buildid'].isdigit())
self.assertTrue(build_info['locale'])
- self.assertIn('force=1', build_info['url_aus'])
+ self.assertIn('force=1', build_info['update_url'])
+ self.assertIn('xml', build_info['update_snippet'])
self.assertEqual(build_info['channel'], self.software_update.update_channel.channel)
def test_force_fallback(self):
status_file = os.path.join(self.software_update.staging_directory, 'update.status')
try:
self.software_update.force_fallback()
with open(status_file, 'r') as f:
--- a/testing/puppeteer/firefox/firefox_puppeteer/api/software_update.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/api/software_update.py
@@ -215,23 +215,26 @@ class SoftwareUpdate(BaseLib):
""")
@property
def build_info(self):
"""Return information of the current build version
:returns: A dictionary of build information
"""
+ update_url = self.get_update_url(True)
+
return {
'buildid': self.app_info.appBuildID,
'channel': self.update_channel.channel,
'disabled_addons': self.prefs.get_pref(self.PREF_DISABLED_ADDONS),
'locale': self.app_info.locale,
'mar_channels': self.mar_channels.channels,
- 'url_aus': self.get_update_url(True),
+ 'update_url': update_url,
+ 'update_snippet': self.get_update_snippet(update_url),
'user_agent': self.app_info.user_agent,
'version': self.app_info.version
}
@property
def is_complete_update(self):
"""Return true if the offered update is a complete update
@@ -324,16 +327,31 @@ class SoftwareUpdate(BaseLib):
"""Returns the type of the active update."""
return self.active_update.type
def force_fallback(self):
"""Update the update.status file and set the status to 'failed:6'"""
with open(os.path.join(self.staging_directory, 'update.status'), 'w') as f:
f.write('failed: 6\n')
+ def get_update_snippet(self, update_url):
+ """Retrieve contents of the update snippet.
+
+ :param update_url: URL to the update snippet
+ """
+ snippet = None
+ try:
+ import urllib2
+ response = urllib2.urlopen(update_url)
+ snippet = response.read()
+ except Exception:
+ pass
+
+ return snippet
+
def get_update_url(self, force=False):
"""Retrieve the AUS update URL the update snippet is retrieved from.
:param force: Boolean flag to force an update check
:returns: The URL of the update snippet
"""
url = self.prefs.get_pref(self.PREF_APP_UPDATE_URL_OVERRIDE)