/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.64.1 by Ian Clatworthy
1st cut: gfi parser + --info processing method
1
# Copyright (C) 2008 Canonical Ltd
2
#
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.
7
#
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.
12
#
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
16
17
"""Test the Import errors"""
18
19
from bzrlib import tests
20
21
from bzrlib.plugins.fastimport import (
22
    errors,
23
    )
24
25
26
class TestErrors(tests.TestCase):
27
28
    def test_MissingBytes(self):
29
        e = errors.MissingBytes(99, 10, 8)
30
        self.assertEqual("line 99: Unexpected EOF - expected 10 bytes, found 8",
31
            str(e))
32
33
    def test_MissingTerminator(self):
34
        e = errors.MissingTerminator(99, '---')
35
        self.assertEqual("line 99: Unexpected EOF - expected '---' terminator",
36
            str(e))
37
38
    def test_InvalidCommand(self):
39
        e = errors.InvalidCommand(99, 'foo')
40
        self.assertEqual("line 99: Invalid command 'foo'",
41
            str(e))
42
43
    def test_MissingSection(self):
44
        e = errors.MissingSection(99, 'foo', 'bar')
45
        self.assertEqual("line 99: Command foo is missing section bar",
46
            str(e))
47
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'",
52
            str(e))
53
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.",
59
            str(e))
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."
64
             " Non-numeric hours",
65
             str(e))
66
67
    def test_UnknownDateFormat(self):
68
        e = errors.UnknownDateFormat('aaa')
69
        self.assertEqual("Unknown date format 'aaa'", str(e))
70
71
    def test_MissingHandler(self):
72
        e = errors.MissingHandler('foo')
73
        self.assertEqual("Missing handler for command foo", str(e))