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

Side by Side Diff: appengine/swarming/swarming_bot/os_utilities_test.py

Issue 1308543003: Remove stale android code and remove stand alone functionality. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « appengine/swarming/swarming_bot/os_utilities.py ('k') | 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/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Swarming Authors. All rights reserved. 2 # Copyright 2014 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed by the Apache v2.0 license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import logging 6 import logging
7 import os 7 import os
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 expected = { 122 expected = {
123 u'cost_usd_hour', u'cwd', u'disks', u'gpu', u'ip', u'hostname', 123 u'cost_usd_hour', u'cwd', u'disks', u'gpu', u'ip', u'hostname',
124 u'nb_files_in_temp', u'ram', u'running_time', u'started_ts', 124 u'nb_files_in_temp', u'ram', u'running_time', u'started_ts',
125 } 125 }
126 if sys.platform in ('cygwin', 'win32'): 126 if sys.platform in ('cygwin', 'win32'):
127 expected.add(u'cygwin') 127 expected.add(u'cygwin')
128 if sys.platform == 'win32': 128 if sys.platform == 'win32':
129 expected.add(u'integrity') 129 expected.add(u'integrity')
130 self.assertEqual(expected, set(actual)) 130 self.assertEqual(expected, set(actual))
131 131
132 def test_get_adb_list_devices(self):
133 stdout = (
134 '* daemon not running. starting it now on port 5037 *\n'
135 '* daemon started successfully *\n'
136 'List of devices attached\n'
137 'A12B304C5DE device\n'
138 'emulator-1234 device\n'
139 '\n')
140 self.mock(subprocess, 'check_output', lambda *_: stdout)
141 actual = os_utilities.get_adb_list_devices()
142 self.assertEqual(['A12B304C5DE', 'emulator-1234'], actual)
143
144 def test_get_adb_device_properties_raw(self):
145 stdout = (
146 '# begin build properties\n'
147 '# autogenerated by buildinfo.sh\n'
148 'ro.build.id=KRT16S\n'
149 'ro.build.display.id=KRT16S\n'
150 'ro.build.version.incremental=920375\n'
151 '\n')
152 self.mock(subprocess, 'check_output', lambda *_: stdout)
153 actual = os_utilities.get_adb_device_properties_raw('123')
154 expected = {
155 u'ro.build.display.id': u'KRT16S',
156 u'ro.build.id': u'KRT16S',
157 u'ro.build.version.incremental': u'920375',
158 }
159 self.assertEqual(expected, actual)
160
161 def test_get_dimensions_android(self):
162 props = dict((k, k) for k in os_utilities.ANDROID_DETAILS)
163 props[u'bar'] = u'foo'
164 self.mock(os_utilities, 'get_adb_device_properties_raw', lambda *_: props)
165 actual = os_utilities.get_dimensions_android('123')
166 expected = {
167 u'id': [u'123'],
168 u'ro.board.platform': [u'ro.board.platform'],
169 u'ro.build.id': [u'ro.build.id'],
170 u'ro.build.tags': [u'ro.build.tags'],
171 u'ro.build.type': [u'ro.build.type'],
172 u'ro.build.version.sdk': [u'ro.build.version.sdk'],
173 u'ro.product.board': [u'ro.product.board'],
174 u'ro.product.cpu.abi': [u'ro.product.cpu.abi'],
175 u'ro.product.cpu.abi2': [u'ro.product.cpu.abi2'],
176 }
177 self.assertEqual(expected, actual)
178
179 def test_get_state_android(self):
180 self.mock(time, 'time', lambda: os_utilities._STARTED_TS + 1)
181 expected_dimensions = dict((k, k) for k in os_utilities.ANDROID_DETAILS)
182 props = expected_dimensions.copy()
183 props[u'bar'] = u'foo'
184 self.mock(os_utilities, 'get_adb_device_properties_raw', lambda *_: props)
185
186 expected_dimensions[u'id'] = [u'123']
187 actual = os_utilities.get_state_android('123')
188 expected = {
189 u'device': {},
190 u'host': os_utilities.get_state(),
191 }
192 self.assertEqual(expected, actual)
193
194 def test_setup_auto_startup_win(self): 132 def test_setup_auto_startup_win(self):
195 # TODO(maruel): Figure out a way to test properly. 133 # TODO(maruel): Figure out a way to test properly.
196 pass 134 pass
197 135
198 def test_setup_auto_startup_osx(self): 136 def test_setup_auto_startup_osx(self):
199 # TODO(maruel): Figure out a way to test properly. 137 # TODO(maruel): Figure out a way to test properly.
200 pass 138 pass
201 139
202 def test_restart(self): 140 def test_restart(self):
203 class Foo(Exception): 141 class Foo(Exception):
(...skipping 29 matching lines...) Expand all
233 self.assertFalse(os_utilities.restart(timeout=60)) 171 self.assertFalse(os_utilities.restart(timeout=60))
234 self.assertEqual(time.time(), 60) 172 self.assertEqual(time.time(), 60)
235 173
236 174
237 if __name__ == '__main__': 175 if __name__ == '__main__':
238 if '-v' in sys.argv: 176 if '-v' in sys.argv:
239 unittest.TestCase.maxDiff = None 177 unittest.TestCase.maxDiff = None
240 logging.basicConfig( 178 logging.basicConfig(
241 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 179 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
242 unittest.main() 180 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/swarming_bot/os_utilities.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698