summaryrefslogtreecommitdiff
path: root/gitdb/test/db/test_ref.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2014-11-14 12:45:19 +0100
committerSebastian Thiel <byronimo@gmail.com>2014-11-14 12:45:19 +0100
commit2f2fe4eea8ba4f47e63a7392a1f27f74f5ee925d (patch)
tree176a493d114fab7cc6e930bf318b2339db386cf5 /gitdb/test/db/test_ref.py
parent81707c606b88e971cc359e3e9f3abeeea2204860 (diff)
parent0dcec5a27b341ce58e5ab169f91aa25b2cafec0c (diff)
downloadgitdb-0.6.0.tar.gz
Merge branch 'py2n3'0.6.0
* python 3 compatibility * all tests work in py2.6, 2.7, 3.3, 3.4
Diffstat (limited to 'gitdb/test/db/test_ref.py')
-rw-r--r--gitdb/test/db/test_ref.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/gitdb/test/db/test_ref.py b/gitdb/test/db/test_ref.py
index 1637bff..db93082 100644
--- a/gitdb/test/db/test_ref.py
+++ b/gitdb/test/db/test_ref.py
@@ -2,59 +2,58 @@
#
# This module is part of GitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
-from lib import *
+from gitdb.test.db.lib import (
+ TestDBBase,
+ with_rw_directory,
+ fixture_path
+)
from gitdb.db import ReferenceDB
from gitdb.util import (
- NULL_BIN_SHA,
- hex_to_bin
- )
+ NULL_BIN_SHA,
+ hex_to_bin
+)
import os
-
+
class TestReferenceDB(TestDBBase):
-
+
def make_alt_file(self, alt_path, alt_list):
"""Create an alternates file which contains the given alternates.
The list can be empty"""
alt_file = open(alt_path, "wb")
for alt in alt_list:
- alt_file.write(alt + "\n")
+ alt_file.write(alt.encode("utf-8") + "\n".encode("ascii"))
alt_file.close()
-
+
@with_rw_directory
def test_writing(self, path):
- NULL_BIN_SHA = '\0' * 20
-
alt_path = os.path.join(path, 'alternates')
rdb = ReferenceDB(alt_path)
assert len(rdb.databases()) == 0
assert rdb.size() == 0
assert len(list(rdb.sha_iter())) == 0
-
+
# try empty, non-existing
assert not rdb.has_object(NULL_BIN_SHA)
-
-
+
# setup alternate file
# add two, one is invalid
own_repo_path = fixture_path('../../../.git/objects') # use own repo
self.make_alt_file(alt_path, [own_repo_path, "invalid/path"])
rdb.update_cache()
assert len(rdb.databases()) == 1
-
+
# we should now find a default revision of ours
gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
assert rdb.has_object(gitdb_sha)
-
+
# remove valid
self.make_alt_file(alt_path, ["just/one/invalid/path"])
rdb.update_cache()
assert len(rdb.databases()) == 0
-
+
# add valid
self.make_alt_file(alt_path, [own_repo_path])
rdb.update_cache()
assert len(rdb.databases()) == 1
-
-