30
30
from bzrlib.tests import TestCase
32
_working_revision_bencode1 = ('d'
33
'9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>'
34
'14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7'
35
'7:message35:(Jelmer) Move dpush to InterBranch.'
32
_working_revision_bencode1 = ('l'
34
'l9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>e'
36
'l10:propertiesd11:branch-nick6:+trunkee'
37
'l9:timestamp14:1242300770.844e'
38
'l11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tze'
37
41
'50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc'
38
'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeoe'
39
'10:propertiesd11:branch-nick6:+trunke'
40
'11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz'
41
'9:timestamp14:1242300770.8448:timezonei3600ee')
42
'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo'
44
'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e'
45
'l7:message35:(Jelmer) Move dpush to InterBranch.e'
43
_working_revision_bencode1_no_timestamp = ('d'
44
'9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>'
45
'14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7'
46
'7:message35:(Jelmer) Move dpush to InterBranch.'
48
_working_revision_bencode1_no_timezone = ('l'
50
'l9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>e'
51
'l9:timestamp14:1242300770.844e'
52
'l10:propertiesd11:branch-nick6:+trunkee'
53
'l11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tze'
48
56
'50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc'
49
'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeoe'
50
'10:propertiesd11:branch-nick6:+trunke'
51
'11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz'
52
'9:timestamp14:1242300770.844e')
57
'48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo'
59
'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e'
60
'l7:message35:(Jelmer) Move dpush to InterBranch.e'
55
64
class TestBEncodeSerializer1(TestCase):
58
67
def test_unpack_revision(self):
59
68
"""Test unpacking a revision"""
61
69
rev = chk_bencode_serializer.read_revision_from_string(
62
70
_working_revision_bencode1)
63
71
self.assertEquals(rev.committer,
64
72
"Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>")
65
73
self.assertEquals(rev.inventory_sha1,
66
74
"4a2c7fb50e077699242cf6eb16a61779c7b680a7")
67
self.assertEquals(["pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc",
68
"jelmer@samba.org-20090510012654-jp9ufxquekaokbeo"],
75
self.assertEquals(("pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc",
76
"jelmer@samba.org-20090510012654-jp9ufxquekaokbeo"),
70
78
self.assertEquals("(Jelmer) Move dpush to InterBranch.", rev.message)
71
self.assertEquals("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz",
79
self.assertEquals("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz",
73
81
self.assertEquals({"branch-nick": u"+trunk"}, rev.properties)
74
82
self.assertEquals(3600, rev.timezone)
76
def test_unpack_revision_no_timestamp(self):
77
rev = chk_bencode_serializer.read_revision_from_string(
78
_working_revision_bencode1_no_timestamp)
84
def test_written_form_matches(self):
85
rev = chk_bencode_serializer.read_revision_from_string(
86
_working_revision_bencode1)
87
as_str = chk_bencode_serializer.write_revision_to_string(rev)
88
self.assertEqualDiff(_working_revision_bencode1, as_str)
90
def test_unpack_revision_no_timezone(self):
91
rev = chk_bencode_serializer.read_revision_from_string(
92
_working_revision_bencode1_no_timezone)
79
93
self.assertEquals(None, rev.timezone)
81
95
def assertRoundTrips(self, serializer, orig_rev):