From 4c5dd5d863c416ee7a20d38d94c612eca1bd34c8 Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Tue, 24 Nov 2020 18:48:55 +0000 Subject: [PATCH] [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 Auto-Submit: Edward Lesmes Reviewed-by: Josip Sokcevic --- tests/owners_client_test.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/owners_client_test.py b/tests/owners_client_test.py index 58cc4ccc3..03f127d93 100644 --- a/tests/owners_client_test.py +++ b/tests/owners_client_test.py @@ -112,5 +112,38 @@ class DepotToolsClientTest(unittest.TestCase): 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()