/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_chk_serializer.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-03 14:14:31 UTC
  • mto: This revision was merged to the branch mainline in revision 4410.
  • Revision ID: john@arbash-meinel.com-20090603141431-zeurvzs2iezwzdn5
A bit of code restructuring.
Move bzrlib/_bencode_py.py back to bzrlib/util/_bencode_py.py
Leaving it as _bencode_py.py so that people don't accidentally
import the old version.
Renaming _bencode_c.pyx => _bencode_pyx.pyx to conform to new naming scheme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    )
30
30
from bzrlib.tests import TestCase
31
31
 
32
 
_working_revision_bencode1 = ('l'
33
 
    'l6:formati10ee'
34
 
    'l9:committer54:Canonical.com Patch Queue Manager <pqm@pqm.ubuntu.com>e'
35
 
    'l8:timezonei3600ee'
36
 
    'l10:propertiesd11:branch-nick6:+trunkee'
37
 
    'l9:timestamp14:1242300770.844e'
38
 
    'l11:revision-id50:pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tze'
39
 
    'l10:parent-ids'
40
 
        'l'
 
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.'
 
36
    '10:parent-idsl'
41
37
        '50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc'
42
 
        '48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo'
43
 
        'ee'
44
 
    'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e'
45
 
    'l7:message35:(Jelmer) Move dpush to InterBranch.e'
46
 
    'e')
 
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')
47
42
 
48
 
_working_revision_bencode1_no_timezone = ('l'
49
 
    'l6:formati10ee'
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'
54
 
    'l10:parent-ids'
55
 
        'l'
 
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.'
 
47
    '10:parent-idsl'
56
48
        '50:pqm@pqm.ubuntu.com-20090514104039-kggemn7lrretzpvc'
57
 
        '48:jelmer@samba.org-20090510012654-jp9ufxquekaokbeo'
58
 
        'ee'
59
 
    'l14:inventory-sha140:4a2c7fb50e077699242cf6eb16a61779c7b680a7e'
60
 
    'l7:message35:(Jelmer) Move dpush to InterBranch.e'
61
 
    'e')
 
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')
62
53
 
63
54
 
64
55
class TestBEncodeSerializer1(TestCase):
66
57
 
67
58
    def test_unpack_revision(self):
68
59
        """Test unpacking a revision"""
 
60
        inp = StringIO()
69
61
        rev = chk_bencode_serializer.read_revision_from_string(
70
62
                _working_revision_bencode1)
71
63
        self.assertEquals(rev.committer,
76
68
            "jelmer@samba.org-20090510012654-jp9ufxquekaokbeo"],
77
69
            rev.parent_ids)
78
70
        self.assertEquals("(Jelmer) Move dpush to InterBranch.", rev.message)
79
 
        self.assertEquals("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz",
 
71
        self.assertEquals("pqm@pqm.ubuntu.com-20090514113250-jntkkpminfn3e0tz", 
80
72
           rev.revision_id)
81
73
        self.assertEquals({"branch-nick": u"+trunk"}, rev.properties)
82
74
        self.assertEquals(3600, rev.timezone)
83
75
 
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)
89
 
 
90
 
    def test_unpack_revision_no_timezone(self):
91
 
        rev = chk_bencode_serializer.read_revision_from_string(
92
 
            _working_revision_bencode1_no_timezone)
 
76
    def test_unpack_revision_no_timestamp(self):
 
77
        rev = chk_bencode_serializer.read_revision_from_string(
 
78
            _working_revision_bencode1_no_timestamp)
93
79
        self.assertEquals(None, rev.timezone)
94
80
 
95
81
    def assertRoundTrips(self, serializer, orig_rev):