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 ( |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
25 |
CommitSupplement, |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
26 |
deserialize_fileid_map, |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
27 |
extract_bzr_metadata, |
28 |
generate_roundtripping_metadata, |
|
29 |
inject_bzr_metadata, |
|
30 |
parse_roundtripping_metadata, |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
31 |
serialize_fileid_map, |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
32 |
)
|
|
0.252.1
by Jelmer Vernooij
Support storing revision id data. |
33 |
|
34 |
||
35 |
class RoundtripTests(TestCase): |
|
36 |
||
37 |
def test_revid(self): |
|
38 |
md = parse_roundtripping_metadata("revision-id: foo\n") |
|
39 |
self.assertEquals("foo", md.revision_id) |
|
40 |
||
|
0.252.9
by Jelmer Vernooij
add extra tests. |
41 |
def test_parent_ids(self): |
42 |
md = parse_roundtripping_metadata("parent-ids: foo bar\n") |
|
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
43 |
self.assertEquals(("foo", "bar"), md.explicit_parent_ids) |
44 |
||
45 |
def test_properties(self): |
|
46 |
md = parse_roundtripping_metadata("property-foop: blar\n") |
|
47 |
self.assertEquals({"foop": "blar"}, md.properties) |
|
|
0.252.9
by Jelmer Vernooij
add extra tests. |
48 |
|
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
49 |
|
50 |
class FormatTests(TestCase): |
|
51 |
||
|
0.252.9
by Jelmer Vernooij
add extra tests. |
52 |
def test_revid(self): |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
53 |
metadata = CommitSupplement() |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
54 |
metadata.revision_id = "bla" |
55 |
self.assertEquals("revision-id: bla\n", |
|
|
0.252.41
by Jelmer Vernooij
Fix Repository.all_revision_ids. |
56 |
generate_roundtripping_metadata(metadata, "utf-8")) |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
57 |
|
|
0.252.9
by Jelmer Vernooij
add extra tests. |
58 |
def test_parent_ids(self): |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
59 |
metadata = CommitSupplement() |
|
0.252.9
by Jelmer Vernooij
add extra tests. |
60 |
metadata.explicit_parent_ids = ("foo", "bar") |
61 |
self.assertEquals("parent-ids: foo bar\n", |
|
|
0.252.41
by Jelmer Vernooij
Fix Repository.all_revision_ids. |
62 |
generate_roundtripping_metadata(metadata, "utf-8")) |
|
0.252.9
by Jelmer Vernooij
add extra tests. |
63 |
|
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
64 |
def test_properties(self): |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
65 |
metadata = CommitSupplement() |
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
66 |
metadata.properties = {"foo": "bar"} |
67 |
self.assertEquals("property-foo: bar\n", |
|
|
0.252.41
by Jelmer Vernooij
Fix Repository.all_revision_ids. |
68 |
generate_roundtripping_metadata(metadata, "utf-8")) |
|
0.252.10
by Jelmer Vernooij
Support roundtripping custom revision properties. |
69 |
|
|
0.200.1019
by Jelmer Vernooij
Handle empty metadata. |
70 |
def test_empty(self): |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
71 |
metadata = CommitSupplement() |
|
0.200.1019
by Jelmer Vernooij
Handle empty metadata. |
72 |
self.assertEquals("", |
73 |
generate_roundtripping_metadata(metadata, "utf-8")) |
|
74 |
||
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
75 |
|
76 |
class ExtractMetadataTests(TestCase): |
|
77 |
||
78 |
def test_roundtrip(self): |
|
79 |
(msg, metadata) = extract_bzr_metadata("""Foo |
|
80 |
--BZR--
|
|
81 |
revision-id: foo
|
|
82 |
""") |
|
83 |
self.assertEquals("Foo", msg) |
|
84 |
self.assertEquals("foo", metadata.revision_id) |
|
85 |
||
86 |
||
87 |
class GenerateMetadataTests(TestCase): |
|
88 |
||
89 |
def test_roundtrip(self): |
|
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
90 |
metadata = CommitSupplement() |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
91 |
metadata.revision_id = "myrevid" |
|
0.252.41
by Jelmer Vernooij
Fix Repository.all_revision_ids. |
92 |
msg = inject_bzr_metadata("Foo", metadata, "utf-8") |
|
0.252.2
by Jelmer Vernooij
Add functions for adding metadata to revision messages. |
93 |
self.assertEquals("""Foo |
94 |
--BZR--
|
|
95 |
revision-id: myrevid
|
|
96 |
""", msg) |
|
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
97 |
|
|
0.200.1019
by Jelmer Vernooij
Handle empty metadata. |
98 |
def test_no_metadata(self): |
|
0.200.1324
by Jelmer Vernooij
More work on roundtripping support. |
99 |
metadata = CommitSupplement() |
|
0.200.1019
by Jelmer Vernooij
Handle empty metadata. |
100 |
msg = inject_bzr_metadata("Foo", metadata, "utf-8") |
101 |
self.assertEquals("Foo", msg) |
|
102 |
||
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
103 |
|
104 |
class FileIdRoundTripTests(TestCase): |
|
105 |
||
106 |
def test_deserialize(self): |
|
107 |
self.assertEquals({"bar/bla": "fid"}, |
|
108 |
deserialize_fileid_map("bar/bla\0fid\n")) |
|
109 |
||
110 |
def test_serialize(self): |
|
|
0.252.23
by Jelmer Vernooij
More work on roundtripping support. |
111 |
self.assertEquals(["bar/bla\0fid\n"], |
|
0.252.22
by Jelmer Vernooij
Fix file id map (de)serialization. |
112 |
serialize_fileid_map({"bar/bla": "fid"})) |
113 |