| OLD | NEW |
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Helpers for mocking auth stuff in unit tests. | 5 """Helpers for mocking auth stuff in unit tests. |
| 6 | 6 |
| 7 Must not be used from main application code, only from unit tests. | 7 Must not be used from main application code, only from unit tests. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 from components import utils | 10 from components import utils |
| 11 | 11 |
| 12 from components.auth import api | 12 from components.auth import api |
| 13 from components.auth import handler | 13 from components.auth import handler |
| (...skipping 26 matching lines...) Expand all Loading... |
| 40 orig = api.is_group_member | 40 orig = api.is_group_member |
| 41 def mocked_is_group_member(group, ident): | 41 def mocked_is_group_member(group, ident): |
| 42 if group == model.ADMIN_GROUP: | 42 if group == model.ADMIN_GROUP: |
| 43 return value | 43 return value |
| 44 return orig(group, ident) | 44 return orig(group, ident) |
| 45 test_case.mock(api, 'is_group_member', mocked_is_group_member) | 45 test_case.mock(api, 'is_group_member', mocked_is_group_member) |
| 46 | 46 |
| 47 | 47 |
| 48 # reset_local_state must be called only in tests, so expose it here. | 48 # reset_local_state must be called only in tests, so expose it here. |
| 49 reset_local_state = api.reset_local_state | 49 reset_local_state = api.reset_local_state |
| OLD | NEW |