[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: Josip Sokcevic <sokcevic@google.com>
diff --git a/tests/owners_client_test.py b/tests/owners_client_test.py
index 58cc4cc..03f127d 100644
--- a/tests/owners_client_test.py
+++ b/tests/owners_client_test.py
@@ -112,5 +112,38 @@
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__':
unittest.main()