~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-26 07:08:25 UTC
  • mfrom: (2425.6.3 gmtime)
  • Revision ID: pqm@pqm.ubuntu.com-20070426070825-6xw10b1el98su02i
Correct the handling of timezones and epoch time in bundles

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
class TestMergeDirective(tests.TestCase):
69
69
 
70
70
    def test_merge_source(self):
71
 
        time = 500.0
72
 
        timezone = 5
 
71
        time = 500000.0
 
72
        timezone = 5 * 3600
73
73
        self.assertRaises(errors.NoMergeSource, merge_directive.MergeDirective,
74
74
            'example:', 'sha', time, timezone, 'http://example.com')
75
75
        self.assertRaises(errors.NoMergeSource, merge_directive.MergeDirective,
87
87
 
88
88
    def test_require_patch(self):
89
89
        time = 500.0
90
 
        timezone = 5
 
90
        timezone = 120
91
91
        self.assertRaises(errors.PatchMissing, merge_directive.MergeDirective,
92
92
            'example:', 'sha', time, timezone, 'http://example.com',
93
93
            patch_type='bundle')
97
97
        self.assertEqual(md.patch, '')
98
98
 
99
99
    def test_serialization(self):
100
 
        time = 501
101
 
        timezone = 72
 
100
        time = 453
 
101
        timezone = 120
102
102
        md = merge_directive.MergeDirective('example:', 'sha', time, timezone,
103
103
            'http://example.com', patch='booga', patch_type='bundle')
104
104
        self.assertEqualDiff(OUTPUT1, ''.join(md.to_lines()))
108
108
        self.assertEqualDiff(OUTPUT2, ''.join(md.to_lines()))
109
109
 
110
110
    def test_deserialize_junk(self):
 
111
        time = 501
111
112
        self.assertRaises(errors.NotAMergeDirective,
112
113
                          merge_directive.MergeDirective.from_lines, 'lala')
113
114
 
121
122
        self.assertEqual('sha', md.testament_sha1)
122
123
        self.assertEqual('http://example.com', md.target_branch)
123
124
        self.assertEqual('http://example.org', md.source_branch)
124
 
        self.assertEqual(501, md.time)
125
 
        self.assertEqual(72, md.timezone)
 
125
        self.assertEqual(453, md.time)
 
126
        self.assertEqual(120, md.timezone)
126
127
        self.assertEqual('booga', md.patch)
127
128
        self.assertEqual('diff', md.patch_type)
128
129
        self.assertEqual('Hi mom!', md.message)
129
130
 
130
131
    def test_roundtrip(self):
131
 
        time = 501
132
 
        timezone = 72
 
132
        time = 500000
 
133
        timezone = 7.5 * 3600
133
134
        md = merge_directive.MergeDirective('example:', 'sha', time, timezone,
134
135
            'http://example.com', source_branch="http://example.org",
135
136
            patch='booga', patch_type='diff')
204
205
    def test_generate_patch(self):
205
206
        tree_a, tree_b, branch_c = self.make_trees()
206
207
        md2 = merge_directive.MergeDirective.from_objects(
207
 
            tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
 
208
            tree_a.branch.repository, 'rev2a', 500, 120, tree_b.branch.base,
208
209
            patch_type='diff', public_branch=tree_a.branch.base)
209
210
        self.assertNotContainsRe(md2.patch, 'Bazaar revision bundle')
210
211
        self.assertContainsRe(md2.patch, '\\+content_c')
246
247
    def test_message(self):
247
248
        tree_a, tree_b, branch_c = self.make_trees()
248
249
        md3 = merge_directive.MergeDirective.from_objects(
249
 
            tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
 
250
            tree_a.branch.repository, 'rev2a', 500, 120, tree_b.branch.base,
250
251
            patch_type=None, public_branch=branch_c.base,
251
252
            message='Merge message')
252
253
        md3.to_lines()
256
257
    def test_generate_bundle(self):
257
258
        tree_a, tree_b, branch_c = self.make_trees()
258
259
        md1 = merge_directive.MergeDirective.from_objects(
259
 
            tree_a.branch.repository, 'rev2a', 500, 144, tree_b.branch.base,
 
260
            tree_a.branch.repository, 'rev2a', 500, 120, tree_b.branch.base,
260
261
            public_branch=branch_c.base)
261
262
        self.assertContainsRe(md1.patch, 'Bazaar revision bundle')
262
263
        self.assertContainsRe(md1.patch, '\\+content_c')
265
266
        self.assertNotContainsRe(md1.patch, '\\+content_a')
266
267
 
267
268
    def test_signing(self):
268
 
        time = 501
269
 
        timezone = 72
 
269
        time = 453
 
270
        timezone = 7200
270
271
        class FakeBranch(object):
271
272
            def get_config(self):
272
273
                return self
288
289
    def test_email(self):
289
290
        tree_a, tree_b, branch_c = self.make_trees()
290
291
        md = merge_directive.MergeDirective.from_objects(
291
 
            tree_a.branch.repository, 'rev2a', 500, 36, tree_b.branch.base,
 
292
            tree_a.branch.repository, 'rev2a', 476, 60, tree_b.branch.base,
292
293
            patch_type=None, public_branch=tree_a.branch.base)
293
294
        message = md.to_email('pqm@example.com', tree_a.branch)
294
295
        self.assertContainsRe(message.as_string(), EMAIL1)