Commit 743e98ce authored by Edward Lesmes's avatar Edward Lesmes Committed by LUCI CQ

gerrit_util: Fix checking if code-owners enabled on repo.

Change-Id: I5f518c22be4c5496f91202015c9caf18d0fa1be9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2778638
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarJason Clinton <jclinton@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 993b65e4
......@@ -783,7 +783,7 @@ def IsCodeOwnersEnabledOnRepo(host, repo):
repo = PercentEncodeForGitRef(repo)
path = '/projects/%s/code_owners.project_config' % repo
config = ReadHttpJsonResponse(CreateHttpConn(host, path))
return config['status'].get('disabled', False)
return not config['status'].get('disabled', False)
def GetOwnersForFile(host, project, branch, path, limit=100,
......
......@@ -481,6 +481,19 @@ class GerritUtilTest(unittest.TestCase):
],
mockQueryChanges.mock_calls)
@mock.patch('gerrit_util.CreateHttpConn')
@mock.patch('gerrit_util.ReadHttpJsonResponse')
def testIsCodeOwnersEnabledOnRepo_Disabled(
self, mockJsonResponse, mockCreateHttpConn):
mockJsonResponse.return_value = {'status': {'disabled': True}}
self.assertFalse(gerrit_util.IsCodeOwnersEnabledOnRepo('host', 'repo'))
@mock.patch('gerrit_util.CreateHttpConn')
@mock.patch('gerrit_util.ReadHttpJsonResponse')
def testIsCodeOwnersEnabledOnRepo_Enabled(
self, mockJsonResponse, mockCreateHttpConn):
mockJsonResponse.return_value = {'status': {}}
self.assertTrue(gerrit_util.IsCodeOwnersEnabledOnRepo('host', 'repo'))
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment