summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_blob.py17
-rw-r--r--test/test_commit.py2
-rw-r--r--test/test_reflog.py32
-rw-r--r--test/test_refs.py2
-rw-r--r--test/test_tree.py3
5 files changed, 49 insertions, 7 deletions
diff --git a/test/test_blob.py b/test/test_blob.py
index 8513328e..661c0501 100644
--- a/test/test_blob.py
+++ b/test/test_blob.py
@@ -9,12 +9,15 @@ from git import *
from gitdb.util import hex_to_bin
class TestBlob(TestBase):
-
- def test_mime_type_should_return_mime_type_for_known_types(self):
- blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'foo.png'})
- assert_equal("image/png", blob.mime_type)
+
+ def test_mime_type_should_return_mime_type_for_known_types(self):
+ blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'foo.png'})
+ assert_equal("image/png", blob.mime_type)
- def test_mime_type_should_return_text_plain_for_unknown_types(self):
- blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA,'path': 'something'})
- assert_equal("text/plain", blob.mime_type)
+ def test_mime_type_should_return_text_plain_for_unknown_types(self):
+ blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA,'path': 'something'})
+ assert_equal("text/plain", blob.mime_type)
+ def test_nodict(self):
+ self.failUnlessRaises(AttributeError, setattr, self.rorepo.tree()['AUTHORS'], 'someattr', 2)
+
diff --git a/test/test_commit.py b/test/test_commit.py
index a00a8de8..4a8d8b87 100644
--- a/test/test_commit.py
+++ b/test/test_commit.py
@@ -70,6 +70,8 @@ class TestCommit(TestBase):
def test_bake(self):
commit = self.rorepo.commit('2454ae89983a4496a445ce347d7a41c0bb0ea7ae')
+ # commits have no dict
+ self.failUnlessRaises(AttributeError, setattr, commit, 'someattr', 1)
commit.author # bake
assert_equal("Sebastian Thiel", commit.author.name)
diff --git a/test/test_reflog.py b/test/test_reflog.py
new file mode 100644
index 00000000..efcc7f33
--- /dev/null
+++ b/test/test_reflog.py
@@ -0,0 +1,32 @@
+from git.test.lib import *
+from git.objects import IndexObject, Actor
+from git.refs import *
+
+class TestRefLog(TestBase):
+
+ def test_reflogentry(self):
+ nullhexsha = IndexObject.NULL_HEX_SHA
+ hexsha = 'F' * 40
+ actor = Actor('name', 'email')
+ msg = "message"
+
+ self.failUnlessRaises(ValueError, RefLogEntry.new, nullhexsha, hexsha, 'noactor', 0, 0, "")
+ e = RefLogEntry.new(nullhexsha, hexsha, actor, 0, 1, msg)
+
+ assert e.oldhexsha == nullhexsha
+ assert e.newhexsha == hexsha
+ assert e.actor == actor
+ assert e.time[0] == 0
+ assert e.time[1] == 1
+ assert e.message == msg
+
+ # check representation (roughly)
+ assert repr(e).startswith(nullhexsha)
+
+ def test_base(self):
+ pass
+ # raise on invalid revlog
+ # TODO: Try multiple corrupted ones !
+
+
+ # test serialize and deserialize - results must match exactly
diff --git a/test/test_refs.py b/test/test_refs.py
index 700e5fac..ebf1a00d 100644
--- a/test/test_refs.py
+++ b/test/test_refs.py
@@ -33,6 +33,8 @@ class TestRefs(TestBase):
if tag.tag is not None:
tag_object_refs.append( tag )
tagobj = tag.tag
+ # have no dict
+ self.failUnlessRaises(AttributeError, setattr, tagobj, 'someattr', 1)
assert isinstance( tagobj, TagObject )
assert tagobj.tag == tag.name
assert isinstance( tagobj.tagger, Actor )
diff --git a/test/test_tree.py b/test/test_tree.py
index 80db2e4b..ec10e962 100644
--- a/test/test_tree.py
+++ b/test/test_tree.py
@@ -23,6 +23,9 @@ class TestTree(TestBase):
continue
# END skip non-trees
tree = item
+ # trees have no dict
+ self.failUnlessRaises(AttributeError, setattr, tree, 'someattr', 1)
+
orig_data = tree.data_stream.read()
orig_cache = tree._cache