/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.252.1 by Jelmer Vernooij
Support storing revision id data.
1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2
# -*- encoding: utf-8 -*-
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
19
"""Tests for roundtripping text parsing."""
20
21
22
from bzrlib.tests import TestCase
23
0.252.2 by Jelmer Vernooij
Add functions for adding metadata to revision messages.
24
from bzrlib.plugins.git.roundtrip import (
25
    BzrGitRevisionMetadata,
26
    extract_bzr_metadata,
27
    generate_roundtripping_metadata,
28
    inject_bzr_metadata,
29
    parse_roundtripping_metadata,
30
    )
0.252.1 by Jelmer Vernooij
Support storing revision id data.
31
32
33
class RoundtripTests(TestCase):
34
35
    def test_revid(self):
36
        md = parse_roundtripping_metadata("revision-id: foo\n")
37
        self.assertEquals("foo", md.revision_id)
38
0.252.2 by Jelmer Vernooij
Add functions for adding metadata to revision messages.
39
40
class FormatTests(TestCase):
41
42
    def test_simple(self):
43
        metadata = BzrGitRevisionMetadata()
44
        metadata.revision_id = "bla"
45
        self.assertEquals("revision-id: bla\n",
46
            generate_roundtripping_metadata(metadata))
47
48
49
class ExtractMetadataTests(TestCase):
50
51
    def test_roundtrip(self):
52
        (msg, metadata) = extract_bzr_metadata("""Foo
53
--BZR--
54
revision-id: foo
55
""")
56
        self.assertEquals("Foo", msg)
57
        self.assertEquals("foo", metadata.revision_id)
58
59
60
class GenerateMetadataTests(TestCase):
61
62
    def test_roundtrip(self):
63
        metadata = BzrGitRevisionMetadata()
64
        metadata.revision_id = "myrevid"
65
        msg = inject_bzr_metadata("Foo", metadata)
66
        self.assertEquals("""Foo
67
--BZR--
68
revision-id: myrevid
69
""", msg)