1 # test_fastexport.py -- Fast export/import functionality
2 # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
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 or (at your option) any later version of
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 from cStringIO import StringIO
23 from dulwich.fastexport import (
26 from dulwich.object_store import (
29 from dulwich.objects import (
34 from dulwich.tests import (
39 class FastExporterTests(TestCase):
42 super(FastExporterTests, self).setUp()
43 self.store = MemoryObjectStore()
44 self.stream = StringIO()
45 self.fastexporter = FastExporter(self.stream, self.store)
47 def test_export_blob(self):
50 self.assertEquals(1, self.fastexporter.export_blob(b))
51 self.assertEquals('blob\nmark :1\ndata 6\nfooBAR\n',
52 self.stream.getvalue())
54 def test_export_commit(self):
58 t.add(stat.S_IFREG | 0644, "foo", b.id)
60 c.committer = c.author = "Jelmer <jelmer@host>"
61 c.author_time = c.commit_time = 1271345553.47
62 c.author_timezone = c.commit_timezone = 0
65 self.store.add_objects([(b, None), (t, None), (c, None)])
67 self.fastexporter.export_commit(c, "refs/heads/master"))
68 self.assertEquals("""blob
72 commit refs/heads/master
74 author Jelmer <jelmer@host> 1271345553.47 +0000
75 committer Jelmer <jelmer@host> 1271345553.47 +0000
80 """, self.stream.getvalue())