1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Test the Import errors"""
19
from bzrlib import tests
21
from bzrlib.plugins.fastimport import (
26
class TestErrors(tests.TestCase):
28
def test_MissingBytes(self):
29
e = errors.MissingBytes(99, 10, 8)
30
self.assertEqual("line 99: Unexpected EOF - expected 10 bytes, found 8",
33
def test_MissingTerminator(self):
34
e = errors.MissingTerminator(99, '---')
35
self.assertEqual("line 99: Unexpected EOF - expected '---' terminator",
38
def test_InvalidCommand(self):
39
e = errors.InvalidCommand(99, 'foo')
40
self.assertEqual("line 99: Invalid command 'foo'",
43
def test_MissingSection(self):
44
e = errors.MissingSection(99, 'foo', 'bar')
45
self.assertEqual("line 99: Command foo is missing section bar",
48
def test_BadFormat(self):
49
e = errors.BadFormat(99, 'foo', 'bar', 'xyz')
50
self.assertEqual("line 99: Bad format for section bar in "
51
"command foo: found 'xyz'",
54
def test_InvalidTimezone(self):
55
e = errors.InvalidTimezone(99, 'aa:bb')
56
self.assertEqual('aa:bb', e.timezone)
57
self.assertEqual('', e.reason)
58
self.assertEqual("line 99: Timezone 'aa:bb' could not be converted.",
60
e = errors.InvalidTimezone(99, 'aa:bb', 'Non-numeric hours')
61
self.assertEqual('aa:bb', e.timezone)
62
self.assertEqual(' Non-numeric hours', e.reason)
63
self.assertEqual("line 99: Timezone 'aa:bb' could not be converted."
67
def test_UnknownDateFormat(self):
68
e = errors.UnknownDateFormat('aaa')
69
self.assertEqual("Unknown date format 'aaa'", str(e))
71
def test_MissingHandler(self):
72
e = errors.MissingHandler('foo')
73
self.assertEqual("Missing handler for command foo", str(e))