Quellcode durchsuchen

owners: Move constants inside OwnersClient.

When used as part of presubmit's input_api, we only
expose OwnersClient and not global constants, so
move constants inside OwnersClient.

Change-Id: I8983c5edadafeebff62838d9cd4a19fdce908159
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2621744
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Edward Lesmes vor 4 Jahren
Ursprung
Commit
c40b2406de
2 geänderte Dateien mit 10 neuen und 11 gelöschten Zeilen
  1. 7 8
      owners_client.py
  2. 3 3
      tests/owners_client_test.py

+ 7 - 8
owners_client.py

@@ -13,11 +13,6 @@ import owners as owners_db
 import scm
 import scm
 
 
 
 
-APPROVED = 'APPROVED'
-PENDING = 'PENDING'
-INSUFFICIENT_REVIEWERS = 'INSUFFICIENT_REVIEWERS'
-
-
 def _owner_combinations(owners, num_owners):
 def _owner_combinations(owners, num_owners):
   """Iterate owners combinations by decrasing score.
   """Iterate owners combinations by decrasing score.
 
 
@@ -54,6 +49,10 @@ class OwnersClient(object):
   All code should use this class to interact with OWNERS files instead of the
   All code should use this class to interact with OWNERS files instead of the
   owners database in owners.py
   owners database in owners.py
   """
   """
+  APPROVED = 'APPROVED'
+  PENDING = 'PENDING'
+  INSUFFICIENT_REVIEWERS = 'INSUFFICIENT_REVIEWERS'
+
   def ListOwners(self, path):
   def ListOwners(self, path):
     """List all owners for a file.
     """List all owners for a file.
 
 
@@ -85,11 +84,11 @@ class OwnersClient(object):
     for path, owners in owners_by_path.items():
     for path, owners in owners_by_path.items():
       owners = set(owners)
       owners = set(owners)
       if owners.intersection(approvers):
       if owners.intersection(approvers):
-        status[path] = APPROVED
+        status[path] = self.APPROVED
       elif owners.intersection(reviewers):
       elif owners.intersection(reviewers):
-        status[path] = PENDING
+        status[path] = self.PENDING
       else:
       else:
-        status[path] = INSUFFICIENT_REVIEWERS
+        status[path] = self.INSUFFICIENT_REVIEWERS
     return status
     return status
 
 
   def SuggestOwners(self, paths):
   def SuggestOwners(self, paths):

+ 3 - 3
tests/owners_client_test.py

@@ -113,9 +113,9 @@ class OwnersClientTest(unittest.TestCase):
     self.assertEqual(
     self.assertEqual(
         status,
         status,
         {
         {
-            'approved': owners_client.APPROVED,
-            'pending': owners_client.PENDING,
-            'insufficient': owners_client.INSUFFICIENT_REVIEWERS,
+            'approved': owners_client.OwnersClient.APPROVED,
+            'pending': owners_client.OwnersClient.PENDING,
+            'insufficient': owners_client.OwnersClient.INSUFFICIENT_REVIEWERS,
         })
         })
 
 
   def test_owner_combinations(self):
   def test_owner_combinations(self):