OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 2 # |
| 3 # Use of this source code is governed by a BSD-style license |
| 4 # that can be found in the LICENSE file in the root of the source |
| 5 # tree. An additional intellectual property rights grant can be found |
| 6 # in the file PATENTS. All contributing project authors may |
| 7 # be found in the AUTHORS file in the root of the source tree. |
| 8 |
| 9 |
| 10 class MockInputApi(object): |
| 11 """Mock class for the InputApi class. |
| 12 |
| 13 This class can be used for unittests for presubmit by initializing the files |
| 14 attribute as the list of changed files. |
| 15 """ |
| 16 |
| 17 def __init__(self): |
| 18 self.change = MockChange([]) |
| 19 |
| 20 |
| 21 class MockOutputApi(object): |
| 22 """Mock class for the OutputApi class. |
| 23 |
| 24 An instance of this class can be passed to presubmit unittests for outputing |
| 25 various types of results. |
| 26 """ |
| 27 |
| 28 class PresubmitResult(object): |
| 29 def __init__(self, message, items=None, long_text=''): |
| 30 self.message = message |
| 31 self.items = items |
| 32 self.long_text = long_text |
| 33 |
| 34 def __repr__(self): |
| 35 return self.message |
| 36 |
| 37 class PresubmitError(PresubmitResult): |
| 38 def __init__(self, message, items=None, long_text=''): |
| 39 MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) |
| 40 self.type = 'error' |
| 41 |
| 42 class MockChange(object): |
| 43 """Mock class for Change class. |
| 44 |
| 45 This class can be used in presubmit unittests to mock the query of the |
| 46 current change. |
| 47 """ |
| 48 |
| 49 def __init__(self, changed_files): |
| 50 self._changed_files = changed_files |
OLD | NEW |