diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-02 22:40:52 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-02 22:40:52 +0200 |
commit | 8b86f9b399a8f5af792a04025fdeefc02883f3e5 (patch) | |
tree | f10c0bc2e8a95676e1062d2b86676eb0a5294ce1 /test/git/test_odb.py | |
parent | 282018b79cc8df078381097cb3aeb29ff56e83c6 (diff) | |
download | gitpython-8b86f9b399a8f5af792a04025fdeefc02883f3e5.tar.gz |
initial version of loose object writing and simple cached object lookup appears to be working
Diffstat (limited to 'test/git/test_odb.py')
-rw-r--r-- | test/git/test_odb.py | 31 |
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) |