Add some basic tests for fastexport.
[jelmer/dulwich-libgit2.git] / dulwich / tests / test_fastexport.py
1 # test_fastexport.py -- Fast export/import functionality
2 # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
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 or (at your option) any later version of 
8 # the License.
9
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.
14
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,
18 # MA  02110-1301, USA.
19
20 from cStringIO import StringIO
21
22 from dulwich.fastexport import FastExporter
23 from dulwich.object_store import MemoryObjectStore
24 from dulwich.objects import Blob
25
26 from unittest import TestCase
27
28
29 class FastExporterTests(TestCase):
30
31     def setUp(self):
32         super(FastExporterTests, self).setUp()
33         self.store = MemoryObjectStore()
34         self.stream = StringIO()
35         self.fastexporter = FastExporter(self.stream, self.store)
36
37     def test_export_blob(self):
38         b = Blob()
39         b.data = "fooBAR"
40         self.fastexporter.export_blob(b, 0)
41         self.assertEquals('blob\nmark :0\ndata 6\nfooBAR\n',
42             self.stream.getvalue())