Bug 1261101 - Add full update snippet contents to the update results dictionary. r?maja_zf draft
authorHenrik Skupin <mail@hskupin.info>
Mon, 04 Jul 2016 16:55:13 +0200
changeset 383566 f1867cdfdad7cd837cb7dd48e5950e61749adc30
parent 383564 1e65f3ba4aab57020e7728213a4fea2856aa7c04
child 524514 f4c05a8f4617126190577c4c33e8ad6477a8cd76
push id22060
push userbmo:hskupin@gmail.com
push dateMon, 04 Jul 2016 15:58:12 +0000
reviewersmaja_zf
bugs1261101
milestone50.0a1
Bug 1261101 - Add full update snippet contents to the update results dictionary. r?maja_zf MozReview-Commit-ID: sgeTaYlu8P
testing/firefox-ui/tests/puppeteer/manifest.ini
testing/firefox-ui/tests/puppeteer/test_software_update.py
testing/puppeteer/firefox/firefox_puppeteer/api/software_update.py
--- 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)