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

Side by Side Diff: appengine/findit/util_scripts/test/script_util_test.py

Issue 2456603003: [Predator] Add local cache for get command output. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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/findit/util_scripts/test/local_cache_test.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 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import subprocess 5 import subprocess
6 6
7 import script_util 7 import script_util
8 from testing_utils import testing 8 from testing_utils import testing
9 9
10 10
11 class ScriptUtilTest(testing.AppengineTestCase): 11 class ScriptUtilTest(testing.AppengineTestCase):
12 12
13 # TODO(katesonia): Figure out a good way to work around cache.
13 def testGetLocalGitCommandOutput(self): 14 def testGetLocalGitCommandOutput(self):
14 class _MockProcess(object): 15 class _MockProcess(object):
15 def __init__(self, command, *_): 16 def __init__(self, command, *_):
16 self.command = command 17 self.command = command
17 18
18 def communicate(self, *_): 19 def communicate(self, *_):
19 return self.command, 'dummy' 20 return self.command, 'error'
20 21
21 @property 22 @property
22 def returncode(self): 23 def returncode(self):
23 return 1 if self.command == 'dummy' else 0 24 return 1 if self.command == 'dummy' else 0
24 25
25 self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command)) 26 self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command))
26 output = script_util.GetCommandOutput('command') 27 output = script_util.GetCommandOutput('command')
27 self.assertEqual(output, 'command') 28 self.assertEqual(output, 'command')
28 29
29 output = script_util.GetCommandOutput('dummy') 30 output = script_util.GetCommandOutput('dummy')
30 self.assertEqual(output, None) 31 self.assertEqual(output, None)
OLDNEW
« no previous file with comments | « appengine/findit/util_scripts/test/local_cache_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698