/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.211.2 by James Westby
Make it more like a real project.
1
# test_repository.py -- tests for repository.py
2
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
3
# 
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; version 2
7
# of the License.
8
# 
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
# 
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17
# MA  02110-1301, USA.
18
0.211.1 by James Westby
Start the python-git project.
19
import os
20
import unittest
21
22
from git.repository import Repository
23
24
class RepositoryTests(unittest.TestCase):
25
26
  def open_repo(self, name):
27
    return Repository(os.path.join(os.path.dirname(__file__),
28
                      'data/repos', name, '.git'))
29
30
  def test_simple_props(self):
31
    r = self.open_repo('a')
32
    basedir = os.path.join(os.path.dirname(__file__), 'data/repos/a/.git')
33
    self.assertEqual(r.basedir(), basedir)
34
    self.assertEqual(r.object_dir(), os.path.join(basedir, 'objects'))
35
36
  def test_ref(self):
37
    r = self.open_repo('a')
38
    self.assertEqual(r.ref('master'),
39
                     'a90fa2d900a17e99b433217e988c4eb4a2e9a097')
40
41
  def test_head(self):
42
    r = self.open_repo('a')
43
    self.assertEqual(r.head(), 'a90fa2d900a17e99b433217e988c4eb4a2e9a097')
44
45
  def test_get_object(self):
46
    r = self.open_repo('a')
47
    obj = r.get_object(r.head())
48
    self.assertEqual(obj._type, 'commit')
49
50
  def test_get_object_non_existant(self):
51
    r = self.open_repo('a')
52
    obj = r.get_object('b91fa4d900g17e99b433218e988c4eb4a3e9a097')
53
    self.assertEqual(obj, None)
54