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

Side by Side Diff: autoupdate_unittest.py

Issue 4087004: Fix unittests since unittests don't actually send a request. (Closed) Base URL: http://git.chromium.org/git/dev-util.git
Patch Set: Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Unit tests for autoupdate.py.""" 7 """Unit tests for autoupdate.py."""
8 8
9 import cherrypy
9 import mox 10 import mox
10 import os 11 import os
11 import socket 12 import socket
12 import unittest 13 import unittest
13 14
14 import autoupdate 15 import autoupdate
15 16
16 _TEST_REQUEST = """ 17 _TEST_REQUEST = """
17 <client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(c lient)s" > 18 <client_test xmlns:o="http://www.google.com/update2/request" updaterversion="%(c lient)s" >
18 <o:app version="%(version)s" track="%(track)s" board="%(board)s" /> 19 <o:app version="%(version)s" track="%(track)s" board="%(board)s" />
(...skipping 21 matching lines...) Expand all
40 'track': 'unused_var', 41 'track': 'unused_var',
41 'board': self.test_board 42 'board': self.test_board
42 } 43 }
43 self.test_data = _TEST_REQUEST % self.test_dict 44 self.test_data = _TEST_REQUEST % self.test_dict
44 self.forced_image_path = '/path_to_force/chromiumos_image.bin' 45 self.forced_image_path = '/path_to_force/chromiumos_image.bin'
45 self.hash = 12345 46 self.hash = 12345
46 self.size = 54321 47 self.size = 54321
47 self.url = 'http://%s/static/update.gz' % self.hostname 48 self.url = 'http://%s/static/update.gz' % self.hostname
48 self.payload = 'My payload' 49 self.payload = 'My payload'
49 self.sha256 = 'SHA LA LA' 50 self.sha256 = 'SHA LA LA'
51 cherrypy.request.base = 'http://%s' % self.hostname
52
50 53
51 def _DummyAutoupdateConstructor(self): 54 def _DummyAutoupdateConstructor(self):
52 """Creates a dummy autoupdater. Used to avoid using constructor.""" 55 """Creates a dummy autoupdater. Used to avoid using constructor."""
53 dummy = autoupdate.Autoupdate(root_dir=None, 56 dummy = autoupdate.Autoupdate(root_dir=None,
54 static_dir=self.static_image_dir, 57 static_dir=self.static_image_dir,
55 port=self.port) 58 port=self.port)
56 dummy.client_prefix = 'ChromeOSUpdateEngine' 59 dummy.client_prefix = 'ChromeOSUpdateEngine'
57 return dummy 60 return dummy
58 61
59 def testGenerateLatestUpdateImageWithForced(self): 62 def testGenerateLatestUpdateImageWithForced(self):
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 self.mox.ReplayAll() 142 self.mox.ReplayAll()
140 au_mock = self._DummyAutoupdateConstructor() 143 au_mock = self._DummyAutoupdateConstructor()
141 au_mock.serve_only = True 144 au_mock.serve_only = True
142 au_mock.static_urlbase = 'http://%s/static/archive' % self.hostname 145 au_mock.static_urlbase = 'http://%s/static/archive' % self.hostname
143 self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload) 146 self.assertEqual(au_mock.HandleUpdatePing(test_data), self.payload)
144 self.mox.VerifyAll() 147 self.mox.VerifyAll()
145 148
146 149
147 if __name__ == '__main__': 150 if __name__ == '__main__':
148 unittest.main() 151 unittest.main()
OLDNEW
« 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