mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 09:54:42 +00:00
Bug 1290850 - Force local update URL for software update unit tests. r=maja_zf
The unit tests for the software update class should not rely on the remote update URL being reachable. Instead a locally served URL has to be used. MozReview-Commit-ID: 8WNoEb0PUWz --HG-- extra : rebase_source : 85900716de5c868efd8f0411e0c577f317d98d25
This commit is contained in:
parent
f588ac7e28
commit
56bc9b1cb8
3
testing/firefox-ui/resources/update/snippet_empty.xml
Normal file
3
testing/firefox-ui/resources/update/snippet_empty.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<updates>
|
||||
</updates>
|
@ -8,7 +8,6 @@ tags = local
|
||||
[test_security.py]
|
||||
tags = remote
|
||||
[test_software_update.py]
|
||||
tags = remote
|
||||
[test_utils.py]
|
||||
|
||||
# UI tests
|
||||
|
@ -32,16 +32,24 @@ class TestSoftwareUpdate(PuppeteerMixin, MarionetteTestCase):
|
||||
self.assertTrue(self.software_update.allowed)
|
||||
|
||||
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['update_url'])
|
||||
self.assertIn('xml', build_info['update_snippet'])
|
||||
self.assertEqual(build_info['channel'], self.software_update.update_channel)
|
||||
self.software_update.update_url = self.marionette.absolute_url(
|
||||
'update/snippet_empty.xml?product=%PRODUCT%&version=%VERSION%&'
|
||||
'buildid=%BUILD_ID%&locale=%LOCALE%&channel=%CHANNEL%')
|
||||
|
||||
try:
|
||||
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['update_url'])
|
||||
self.assertIn('xml', build_info['update_snippet'])
|
||||
self.assertEqual(build_info['channel'], self.software_update.update_channel)
|
||||
finally:
|
||||
# Restart Firefox to reset the custom update url
|
||||
self.restart(clean=True)
|
||||
|
||||
def test_force_fallback(self):
|
||||
status_file = os.path.join(self.software_update.staging_directory, 'update.status')
|
||||
@ -95,6 +103,7 @@ class TestUpdateChannel(PuppeteerMixin, MarionetteTestCase):
|
||||
# Firefox to dump the logs to the console.
|
||||
self.restart(clean=True)
|
||||
self.assertEqual(self.software_update.update_channel, 'expected_channel')
|
||||
self.assertEqual(self.software_update.patch_info['channel'], 'expected_channel')
|
||||
finally:
|
||||
self.software_update.update_channel = self.saved_channel
|
||||
self.restart(clean=True)
|
||||
|
@ -5,6 +5,7 @@
|
||||
import ConfigParser
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
import mozinfo
|
||||
|
||||
@ -359,15 +360,14 @@ class SoftwareUpdate(BaseLib):
|
||||
|
||||
:param update_url: URL to the update snippet
|
||||
"""
|
||||
snippet = None
|
||||
try:
|
||||
import urllib2
|
||||
response = urllib2.urlopen(update_url)
|
||||
snippet = response.read()
|
||||
return response.read()
|
||||
except Exception:
|
||||
pass
|
||||
exc, val, tb = sys.exc_info()
|
||||
|
||||
return snippet
|
||||
raise exc, "Failed to retrieve update snippet: {}".format(val.reason), tb
|
||||
|
||||
def get_formatted_update_url(self, force=False):
|
||||
"""Retrieve the formatted AUS update URL the update snippet is retrieved from.
|
||||
|
Loading…
Reference in New Issue
Block a user