Prechádzať zdrojové kódy

Test ProtocolGraphWalker.all_wants_satisfied rather than private
_is_satisfied.

Jelmer Vernooij 10 rokov pred
rodič
commit
65ba66009f
2 zmenil súbory, kde vykonal 25 pridanie a 14 odobranie
  1. 4 1
      dulwich/server.py
  2. 21 13
      dulwich/tests/test_server.py

+ 4 - 1
dulwich/server.py

@@ -569,7 +569,10 @@ class ProtocolGraphWalker(object):
             in the current interface they are determined outside this class.
         """
         haves = set(haves)
-        earliest = min([self.store[h].commit_time for h in haves])
+        if haves:
+            earliest = min([self.store[h].commit_time for h in haves])
+        else:
+            earliest = 0
         for want in self._wants:
             if not self._is_satisfied(haves, want, earliest):
                 return False

+ 21 - 13
dulwich/tests/test_server.py

@@ -356,20 +356,28 @@ class ProtocolGraphWalkerTestCase(TestCase):
             TestUploadPackHandler(backend, ['/', 'host=lolcats'], TestProto()),
             self._repo.object_store, self._repo.get_peeled)
 
-    def test_is_satisfied_no_haves(self):
-        self.assertFalse(self._walker._is_satisfied([], ONE, 0))
-        self.assertFalse(self._walker._is_satisfied([], TWO, 0))
-        self.assertFalse(self._walker._is_satisfied([], THREE, 0))
-
-    def test_is_satisfied_have_root(self):
-        self.assertTrue(self._walker._is_satisfied([ONE], ONE, 0))
-        self.assertTrue(self._walker._is_satisfied([ONE], TWO, 0))
-        self.assertTrue(self._walker._is_satisfied([ONE], THREE, 0))
-
-    def test_is_satisfied_have_branch(self):
-        self.assertTrue(self._walker._is_satisfied([TWO], TWO, 0))
+    def test_all_wants_satisfied_no_haves(self):
+        self._walker.set_wants([ONE])
+        self.assertFalse(self._walker.all_wants_satisfied([]))
+        self._walker.set_wants([TWO])
+        self.assertFalse(self._walker.all_wants_satisfied([]))
+        self._walker.set_wants([THREE])
+        self.assertFalse(self._walker.all_wants_satisfied([]))
+
+    def test_all_wants_satisfied_have_root(self):
+        self._walker.set_wants([ONE])
+        self.assertTrue(self._walker.all_wants_satisfied([ONE]))
+        self._walker.set_wants([TWO])
+        self.assertTrue(self._walker.all_wants_satisfied([ONE]))
+        self._walker.set_wants([THREE])
+        self.assertTrue(self._walker.all_wants_satisfied([ONE]))
+
+    def testall_wants_satisfied_have_branch(self):
+        self._walker.set_wants([TWO])
+        self.assertTrue(self._walker.all_wants_satisfied([TWO]))
         # wrong branch
-        self.assertFalse(self._walker._is_satisfied([TWO], THREE, 0))
+        self._walker.set_wants([THREE])
+        self.assertFalse(self._walker.all_wants_satisfied([TWO]))
 
     def test_all_wants_satisfied(self):
         self._walker.set_wants([FOUR, FIVE])