|
@@ -0,0 +1,70 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+"""Tests for revision spec parsing."""
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+from dulwich.objects import (
|
|
|
+ Blob,
|
|
|
+ Commit,
|
|
|
+ Tag,
|
|
|
+ Tree,
|
|
|
+ )
|
|
|
+from dulwich.objectspec import (
|
|
|
+ parse_object,
|
|
|
+ parse_commit_range,
|
|
|
+ )
|
|
|
+from dulwich.repo import MemoryRepo
|
|
|
+from dulwich.tests import (
|
|
|
+ TestCase,
|
|
|
+ )
|
|
|
+from dulwich.tests.utils import (
|
|
|
+ build_commit_graph,
|
|
|
+ make_object,
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+class ParseObjectTests(TestCase):
|
|
|
+ """Test parse_object."""
|
|
|
+
|
|
|
+ def test_nonexistent(self):
|
|
|
+ r = MemoryRepo()
|
|
|
+ self.assertRaises(KeyError, parse_object, r, "thisdoesnotexist")
|
|
|
+
|
|
|
+ def test_blob_by_sha(self):
|
|
|
+ r = MemoryRepo()
|
|
|
+ b = Blob.from_string("Blah")
|
|
|
+ r.object_store.add_object(b)
|
|
|
+ self.assertEquals(b, parse_object(r, b.id))
|
|
|
+
|
|
|
+
|
|
|
+class ParseCommitRangeTests(TestCase):
|
|
|
+ """Test parse_commit_range."""
|
|
|
+
|
|
|
+ def test_nonexistent(self):
|
|
|
+ r = MemoryRepo()
|
|
|
+ self.assertRaises(KeyError, parse_commit_range, r, "thisdoesnotexist")
|
|
|
+
|
|
|
+ def test_commit_by_sha(self):
|
|
|
+ r = MemoryRepo()
|
|
|
+ c1, c2, c3 = build_commit_graph(r.object_store, [[1], [2, 1],
|
|
|
+ [3, 1, 2]])
|
|
|
+ self.assertEquals([c1], list(parse_commit_range(r, c1.id)))
|