Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: autoupdate_unittest.py

Issue 3570001: Fix unit tests for sha256 and other url changes. (Closed) Base URL: http://git.chromium.org/git/dev-util.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: autoupdate_unittest.py
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index d2af440b06282d940459ec0644ad4355a22187c0..688695e9170378461f11f57e3fbcfb150d0924d1 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -16,6 +16,7 @@ import autoupdate
_TEST_REQUEST = """
<client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(client)s" >
<o:app version="%(version)s" track="%(track)s" board="%(board)s" />
+ <o:updatecheck />
</client_test>"""
@@ -24,6 +25,7 @@ class AutoupdateTest(mox.MoxTestBase):
mox.MoxTestBase.setUp(self)
self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetSize')
self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetHash')
+ self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetSHA256')
self.mox.StubOutWithMock(autoupdate.Autoupdate, 'GetUpdatePayload')
self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetLatestImageDir')
self.test_board = 'test-board'
@@ -43,6 +45,7 @@ class AutoupdateTest(mox.MoxTestBase):
self.size = 54321
self.url = 'http://%s/static/update.gz' % self.hostname
self.payload = 'My payload'
+ self.sha256 = 'SHA LA LA'
def _DummyAutoupdateConstructor(self):
"""Creates a dummy autoupdater. Used to avoid using constructor."""
@@ -77,13 +80,17 @@ class AutoupdateTest(mox.MoxTestBase):
test_data = _TEST_REQUEST % self.test_dict
autoupdate.Autoupdate.GenerateUpdateImage(
- self.forced_image_path, self.static_image_dir).AndReturn(True)
+ self.forced_image_path,
+ move_to_static_dir=True,
+ static_image_dir=self.static_image_dir).AndReturn(True)
autoupdate.Autoupdate._GetHash(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.hash)
+ autoupdate.Autoupdate._GetSHA256(os.path.join(
+ self.static_image_dir, 'update.gz')).AndReturn(self.sha256)
autoupdate.Autoupdate._GetSize(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.size)
autoupdate.Autoupdate.GetUpdatePayload(
- self.hash, self.size, self.url).AndReturn(self.payload)
+ self.hash, self.sha256, self.size, self.url).AndReturn(self.payload)
self.mox.ReplayAll()
au_mock = self._DummyAutoupdateConstructor()
@@ -100,10 +107,12 @@ class AutoupdateTest(mox.MoxTestBase):
self.test_board, 'ForcedUpdate', self.static_image_dir).AndReturn(True)
autoupdate.Autoupdate._GetHash(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.hash)
+ autoupdate.Autoupdate._GetSHA256(os.path.join(
+ self.static_image_dir, 'update.gz')).AndReturn(self.sha256)
autoupdate.Autoupdate._GetSize(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.size)
autoupdate.Autoupdate.GetUpdatePayload(
- self.hash, self.size, self.url).AndReturn(self.payload)
+ self.hash, self.sha256, self.size, self.url).AndReturn(self.payload)
self.mox.ReplayAll()
au_mock = self._DummyAutoupdateConstructor()
@@ -119,16 +128,19 @@ class AutoupdateTest(mox.MoxTestBase):
self.static_image_dir).AndReturn(True)
autoupdate.Autoupdate._GetHash(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.hash)
+ autoupdate.Autoupdate._GetSHA256(os.path.join(
+ self.static_image_dir, 'update.gz')).AndReturn(self.sha256)
autoupdate.Autoupdate._GetSize(os.path.join(
self.static_image_dir, 'update.gz')).AndReturn(self.size)
autoupdate.Autoupdate.GetUpdatePayload(
- self.hash, self.size,
+ self.hash, self.sha256, self.size,
'http://%s/static/archive/update.gz' % self.hostname).AndReturn(
self.payload)
self.mox.ReplayAll()
au_mock = self._DummyAutoupdateConstructor()
au_mock.serve_only = True
+ au_mock.static_urlbase = 'http://%s/static/archive' % self.hostname
self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
self.mox.VerifyAll()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698