def test_set_blob(self): tree = M.GitLikeTree() tree.set_blob('/dir/dir2/file', 'file-oid') assert_equal(tree.blobs, {}) assert_equal(tree.get_tree('dir').blobs, {}) assert_equal( tree.get_tree('dir').get_tree('dir2').blobs, {'file': 'file-oid'})
def test_hex(self): tree = M.GitLikeTree() tree.set_blob('/dir/dir2/file', 'file-oid') hex = tree.hex() # check the reprs. In case hex (below) fails, this'll be useful assert_equal(repr(tree.get_tree('dir').get_tree('dir2')), 'b file-oid file') assert_equal(repr(tree), 't 96af1772ecce1e6044e6925e595d9373ffcd2615 dir') # the hex() value shouldn't change, it's an important key assert_equal(hex, '4abba29a43411b9b7cecc1a74f0b27920554350d') # another one should be the same tree2 = M.GitLikeTree() tree2.set_blob('/dir/dir2/file', 'file-oid') hex2 = tree2.hex() assert_equal(hex, hex2)
def test_hex_with_unicode(self): tree = M.GitLikeTree() tree.set_blob(u'/dir/f•º£', 'file-oid') # the hex() value shouldn't change, it's an important key assert_equal(tree.hex(), '51ce65bead2f6452da61d4f6f2e42f8648bf9e4b')