1
# Copyright (C) 2009, 2010, 2011, 2016 Canonical Ltd
1
# Copyright (C) 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
from cStringIO import StringIO
17
24
from bzrlib.chk_serializer import (
18
25
chk_bencode_serializer,
61
68
"""Test unpacking a revision"""
62
69
rev = chk_bencode_serializer.read_revision_from_string(
63
70
_working_revision_bencode1)
64
self.assertEqual(rev.committer,
71
self.assertEquals(rev.committer,
65
72
"Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>")
66
self.assertEqual(rev.inventory_sha1,
73
self.assertEquals(rev.inventory_sha1,
67
74
"4a2c7fb50e077699242cf6eb16a61779c7b680a7")
68
self.assertEqual(["pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc",
75
self.assertEquals(["pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc",
69
76
"jelmer@samba.org-20090510012654-jp9ufxquekaokbeo"],
71
self.assertEqual("(Jelmer) Move dpush to InterBranch.", rev.message)
72
self.assertEqual("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz",
78
self.assertEquals("(Jelmer) Move dpush to InterBranch.", rev.message)
79
self.assertEquals("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz",
74
self.assertEqual({"branch-nick": u"+trunk"}, rev.properties)
75
self.assertEqual(3600, rev.timezone)
81
self.assertEquals({"branch-nick": u"+trunk"}, rev.properties)
82
self.assertEquals(3600, rev.timezone)
77
84
def test_written_form_matches(self):
78
85
rev = chk_bencode_serializer.read_revision_from_string(
83
90
def test_unpack_revision_no_timezone(self):
84
91
rev = chk_bencode_serializer.read_revision_from_string(
85
92
_working_revision_bencode1_no_timezone)
86
self.assertEqual(None, rev.timezone)
93
self.assertEquals(None, rev.timezone)
88
95
def assertRoundTrips(self, serializer, orig_rev):
89
96
text = serializer.write_revision_to_string(orig_rev)
90
97
new_rev = serializer.read_revision_from_string(text)
91
self.assertEqual(orig_rev, new_rev)
98
self.assertEquals(orig_rev, new_rev)
93
100
def test_roundtrips_non_ascii(self):
94
101
rev = Revision("revid1")