Commit 4c5dd5d8 authored by Edward Lesmes's avatar Edward Lesmes Committed by LUCI CQ

[owners] Add tests for GetFilesApprovalStatus

Change-Id: I28b061ceb44c032e2c9eb7da22750a7c25f50bea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2556477
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
parent b35dd76c
...@@ -112,5 +112,38 @@ class DepotToolsClientTest(unittest.TestCase): ...@@ -112,5 +112,38 @@ class DepotToolsClientTest(unittest.TestCase):
self.client.ValidateOwnersConfig('changeid') self.client.ValidateOwnersConfig('changeid')
class TestClient(owners_client.OwnersClient):
def __init__(self, host, owners_by_path):
super(TestClient, self).__init__(host)
self.owners_by_path = owners_by_path
def ListOwnersForFile(self, _project, _branch, path):
return self.owners_by_path[path]
class OwnersClientTest(unittest.TestCase):
def setUp(self):
self.owners = {}
self.client = TestClient('host', self.owners)
def testGetFilesApprovalStatus(self):
self.client.owners_by_path = {
'approved': ['approver@example.com'],
'pending': ['reviewer@example.com'],
'insufficient': ['insufficient@example.com'],
}
status = self.client.GetFilesApprovalStatus(
'project', 'branch',
['approved', 'pending', 'insufficient'],
['approver@example.com'], ['reviewer@example.com'])
self.assertEqual(
status,
{
'approved': owners_client.APPROVED,
'pending': owners_client.PENDING,
'insufficient': owners_client.INSUFFICIENT_REVIEWERS,
})
if __name__ == '__main__': if __name__ == '__main__':
unittest.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