summaryrefslogtreecommitdiff
path: root/test/git/test_odb.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/git/test_odb.py')
-rw-r--r--test/git/test_odb.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/git/test_odb.py b/test/git/test_odb.py
index 6f92a5c1..bc92a493 100644
--- a/test/git/test_odb.py
+++ b/test/git/test_odb.py
@@ -2,11 +2,38 @@
from test.testlib import *
from git.odb.db import *
+from git import Blob
+
+from cStringIO import StringIO
+import os
class TestDB(TestBase):
"""Test the different db class implementations"""
- def test_loose_db(self):
- self.fail("todo")
+ # data
+ two_lines = "1234\nhello world"
+
+ all_data = (two_lines, )
+
+ def _assert_object_writing(self, db):
+ """General tests to verify object writing, compatible to iObjectDBW
+ :note: requires write access to the database"""
+ # start in dry-run mode
+ for dry_run in range(1, -1, -1):
+ for data in self.all_data:
+ for hex_sha in range(2):
+ sha = db.to_object(Blob.type, len(data), StringIO(data), dry_run, hex_sha)
+ assert db.has_object(sha) != dry_run
+ assert len(sha) == 20 + hex_sha * 20
+ # END for each sha type
+ # END for each data set
+ # END for each dry_run mode
+
+ @with_bare_rw_repo
+ def test_writing(self, rwrepo):
+ ldb = LooseObjectDB(os.path.join(rwrepo.git_dir, 'objects'))
+
+ # write data
+ self._assert_object_writing(ldb)