bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2009, 2010, 2011, 2016 Canonical Ltd
|
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
6670.4.1
by Jelmer Vernooij
Update imports. |
17 |
from ..bzr.chk_serializer import ( |
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
18 |
chk_bencode_serializer, |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
19 |
)
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
20 |
from ..revision import ( |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
21 |
Revision, |
22 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
23 |
from . import TestCase |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
24 |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
25 |
_working_revision_bencode1 = (b'l' |
26 |
b'l6:formati10ee' |
|
27 |
b'l9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>e' |
|
28 |
b'l8:timezonei3600ee' |
|
29 |
b'l10:propertiesd11:branch-nick6:+trunkee' |
|
30 |
b'l9:timestamp14:1242300770.844e' |
|
31 |
b'l11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tze' |
|
32 |
b'l10:parent-ids' |
|
33 |
b'l' |
|
34 |
b'50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc' |
|
35 |
b'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo' |
|
36 |
b'ee' |
|
37 |
b'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e' |
|
38 |
b'l7:message35:(Jelmer) Move dpush to InterBranch.e' |
|
39 |
b'e') |
|
4290.1.13
by Jelmer Vernooij
Fix bencode-broken tests. |
40 |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
41 |
_working_revision_bencode1_no_timezone = (b'l' |
42 |
b'l6:formati10ee' |
|
43 |
b'l9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>e' |
|
44 |
b'l9:timestamp14:1242300770.844e' |
|
45 |
b'l10:propertiesd11:branch-nick6:+trunkee' |
|
46 |
b'l11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tze' |
|
47 |
b'l10:parent-ids' |
|
48 |
b'l' |
|
49 |
b'50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc' |
|
50 |
b'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo' |
|
51 |
b'ee' |
|
52 |
b'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e' |
|
53 |
b'l7:message35:(Jelmer) Move dpush to InterBranch.e' |
|
54 |
b'e') |
|
4290.1.13
by Jelmer Vernooij
Fix bencode-broken tests. |
55 |
|
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
56 |
|
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
57 |
class TestBEncodeSerializer1(TestCase): |
58 |
"""Test BEncode serialization""" |
|
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
59 |
|
60 |
def test_unpack_revision(self): |
|
61 |
"""Test unpacking a revision""" |
|
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
62 |
rev = chk_bencode_serializer.read_revision_from_string( |
63 |
_working_revision_bencode1) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
64 |
self.assertEqual(rev.committer, |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
65 |
"Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>") |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
66 |
self.assertEqual(rev.inventory_sha1, |
6973.12.9
by Jelmer Vernooij
More fixes. |
67 |
b"4a2c7fb50e077699242cf6eb16a61779c7b680a7") |
68 |
self.assertEqual([b"pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc", |
|
69 |
b"jelmer@samba.org-20090510012654-jp9ufxquekaokbeo"], |
|
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
70 |
rev.parent_ids) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
71 |
self.assertEqual("(Jelmer) Move dpush to InterBranch.", rev.message) |
6973.12.9
by Jelmer Vernooij
More fixes. |
72 |
self.assertEqual(b"pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz", |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
73 |
rev.revision_id) |
6973.12.9
by Jelmer Vernooij
More fixes. |
74 |
self.assertEqual({u"branch-nick": u"+trunk"}, rev.properties) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
75 |
self.assertEqual(3600, rev.timezone) |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
76 |
|
4398.5.5
by John Arbash Meinel
Update the CHK Serializer to do lots more validation. |
77 |
def test_written_form_matches(self): |
78 |
rev = chk_bencode_serializer.read_revision_from_string( |
|
79 |
_working_revision_bencode1) |
|
80 |
as_str = chk_bencode_serializer.write_revision_to_string(rev) |
|
81 |
self.assertEqualDiff(_working_revision_bencode1, as_str) |
|
82 |
||
83 |
def test_unpack_revision_no_timezone(self): |
|
84 |
rev = chk_bencode_serializer.read_revision_from_string( |
|
85 |
_working_revision_bencode1_no_timezone) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
86 |
self.assertEqual(None, rev.timezone) |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
87 |
|
88 |
def assertRoundTrips(self, serializer, orig_rev): |
|
89 |
text = serializer.write_revision_to_string(orig_rev) |
|
90 |
new_rev = serializer.read_revision_from_string(text) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
91 |
self.assertEqual(orig_rev, new_rev) |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
92 |
|
93 |
def test_roundtrips_non_ascii(self): |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
94 |
rev = Revision(b"revid1") |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
95 |
rev.message = u"\n\xe5me" |
96 |
rev.committer = u'Erik B\xe5gfors' |
|
97 |
rev.timestamp = 1242385452 |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
98 |
rev.inventory_sha1 = b"4a2c7fb50e077699242cf6eb16a61779c7b680a7" |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
99 |
rev.timezone = 3600 |
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
100 |
self.assertRoundTrips(chk_bencode_serializer, rev) |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
101 |
|
102 |
def test_roundtrips_xml_invalid_chars(self): |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
103 |
rev = Revision(b"revid1") |
4290.1.11
by Jelmer Vernooij
Add some simple tests for the CHKRioSerializer to make sure the format doesn't change. |
104 |
rev.message = "\t\ue000" |
105 |
rev.committer = u'Erik B\xe5gfors' |
|
106 |
rev.timestamp = 1242385452 |
|
107 |
rev.timezone = 3600 |
|
6973.9.1
by Jelmer Vernooij
More test fixes. |
108 |
rev.inventory_sha1 = b"4a2c7fb50e077699242cf6eb16a61779c7b680a7" |
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
109 |
self.assertRoundTrips(chk_bencode_serializer, rev) |