~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_versionedfile.py

  • Committer: Jelmer Vernooij
  • Date: 2016-04-03 16:32:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6617.
  • Revision ID: jelmer@jelmer.uk-20160403163231-h72bo0uyek2gikw0
Don't put French text in doc/en/user-reference when LANGUAGE=fr_CH.UTF_8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
2
2
#
3
3
# Authors:
4
4
#   Johan Rydberg <jrydberg@gnu.org>
182
182
            versions = f.versions()
183
183
            self.assertTrue('r0' in versions)
184
184
            self.assertTrue('r1' in versions)
185
 
            self.assertEquals(f.get_lines('r0'), ['a\n', 'b\n'])
186
 
            self.assertEquals(f.get_text('r0'), 'a\nb\n')
187
 
            self.assertEquals(f.get_lines('r1'), ['b\n', 'c\n'])
 
185
            self.assertEqual(f.get_lines('r0'), ['a\n', 'b\n'])
 
186
            self.assertEqual(f.get_text('r0'), 'a\nb\n')
 
187
            self.assertEqual(f.get_lines('r1'), ['b\n', 'c\n'])
188
188
            self.assertEqual(2, len(f))
189
189
            self.assertEqual(2, f.num_versions())
190
190
 
216
216
            self.assertTrue('r0' in versions)
217
217
            self.assertTrue('r1' in versions)
218
218
            self.assertTrue('r2' in versions)
219
 
            self.assertEquals(f.get_lines('r0'), ['a\n', 'b\n'])
220
 
            self.assertEquals(f.get_lines('r1'), ['b\n', 'c\n'])
221
 
            self.assertEquals(f.get_lines('r2'), ['c\n', 'd\n'])
 
219
            self.assertEqual(f.get_lines('r0'), ['a\n', 'b\n'])
 
220
            self.assertEqual(f.get_lines('r1'), ['b\n', 'c\n'])
 
221
            self.assertEqual(f.get_lines('r2'), ['c\n', 'd\n'])
222
222
            self.assertEqual(3, f.num_versions())
223
223
            origins = f.annotate('r1')
224
 
            self.assertEquals(origins[0][0], 'r0')
225
 
            self.assertEquals(origins[1][0], 'r1')
 
224
            self.assertEqual(origins[0][0], 'r0')
 
225
            self.assertEqual(origins[1][0], 'r1')
226
226
            origins = f.annotate('r2')
227
 
            self.assertEquals(origins[0][0], 'r1')
228
 
            self.assertEquals(origins[1][0], 'r2')
 
227
            self.assertEqual(origins[0][0], 'r1')
 
228
            self.assertEqual(origins[1][0], 'r2')
229
229
 
230
230
        verify_file(f)
231
231
        f = self.reopen_file()
595
595
        f.add_lines('r0', [], ['a\n', 'b\n'])
596
596
        f.add_lines('r1', ['r0'], ['c\n', 'b\n'])
597
597
        origins = f.annotate('r1')
598
 
        self.assertEquals(origins[0][0], 'r1')
599
 
        self.assertEquals(origins[1][0], 'r0')
 
598
        self.assertEqual(origins[0][0], 'r1')
 
599
        self.assertEqual(origins[1][0], 'r0')
600
600
 
601
601
        self.assertRaises(RevisionNotPresent,
602
602
            f.annotate, 'foo')
746
746
                                 ['base', 'a_ghost'],
747
747
                                 ['line\n', 'line_b\n', 'line_c\n'])
748
748
        origins = vf.annotate('references_ghost')
749
 
        self.assertEquals(('base', 'line\n'), origins[0])
750
 
        self.assertEquals(('base', 'line_b\n'), origins[1])
751
 
        self.assertEquals(('references_ghost', 'line_c\n'), origins[2])
 
749
        self.assertEqual(('base', 'line\n'), origins[0])
 
750
        self.assertEqual(('base', 'line_b\n'), origins[1])
 
751
        self.assertEqual(('references_ghost', 'line_c\n'), origins[2])
752
752
 
753
753
    def test_readonly_mode(self):
754
754
        t = self.get_transport()
841
841
class TestPlanMergeVersionedFile(TestCaseWithMemoryTransport):
842
842
 
843
843
    def setUp(self):
844
 
        TestCaseWithMemoryTransport.setUp(self)
 
844
        super(TestPlanMergeVersionedFile, self).setUp()
845
845
        mapper = PrefixMapper()
846
846
        factory = make_file_factory(True, mapper)
847
847
        self.vf1 = factory(self.get_transport('root-1'))
904
904
        # we should be able to read from http with a versioned file.
905
905
        vf = self.get_file()
906
906
        # try an empty file access
907
 
        readonly_vf = self.get_factory()('foo', transport.get_transport(
908
 
                self.get_readonly_url('.')))
 
907
        readonly_vf = self.get_factory()('foo',
 
908
            transport.get_transport_from_url(self.get_readonly_url('.')))
909
909
        self.assertEqual([], readonly_vf.versions())
910
910
 
911
911
    def test_readonly_http_works_with_feeling(self):
914
914
        # now with feeling.
915
915
        vf.add_lines('1', [], ['a\n'])
916
916
        vf.add_lines('2', ['1'], ['b\n', 'a\n'])
917
 
        readonly_vf = self.get_factory()('foo', transport.get_transport(
918
 
                self.get_readonly_url('.')))
 
917
        readonly_vf = self.get_factory()('foo',
 
918
            transport.get_transport_from_url(self.get_readonly_url('.')))
919
919
        self.assertEqual(['1', '2'], vf.versions())
920
920
        self.assertEqual(['1', '2'], readonly_vf.versions())
921
921
        for version in readonly_vf.versions():
2746
2746
        return ret
2747
2747
 
2748
2748
    def setUp(self):
2749
 
        TestCase.setUp(self)
 
2749
        super(VirtualVersionedFilesTests, self).setUp()
2750
2750
        self._lines = {}
2751
2751
        self._parent_map = {}
2752
2752
        self.texts = VirtualVersionedFiles(self._get_parent_map,
2768
2768
                          [])
2769
2769
 
2770
2770
    def test_get_sha1s_nonexistent(self):
2771
 
        self.assertEquals({}, self.texts.get_sha1s([("NONEXISTENT",)]))
 
2771
        self.assertEqual({}, self.texts.get_sha1s([("NONEXISTENT",)]))
2772
2772
 
2773
2773
    def test_get_sha1s(self):
2774
2774
        self._lines["key"] = ["dataline1", "dataline2"]
2775
 
        self.assertEquals({("key",): osutils.sha_strings(self._lines["key"])},
 
2775
        self.assertEqual({("key",): osutils.sha_strings(self._lines["key"])},
2776
2776
                           self.texts.get_sha1s([("key",)]))
2777
2777
 
2778
2778
    def test_get_parent_map(self):
2779
2779
        self._parent_map = {"G": ("A", "B")}
2780
 
        self.assertEquals({("G",): (("A",),("B",))},
 
2780
        self.assertEqual({("G",): (("A",),("B",))},
2781
2781
                          self.texts.get_parent_map([("G",), ("L",)]))
2782
2782
 
2783
2783
    def test_get_record_stream(self):
2784
2784
        self._lines["A"] = ["FOO", "BAR"]
2785
2785
        it = self.texts.get_record_stream([("A",)], "unordered", True)
2786
2786
        record = it.next()
2787
 
        self.assertEquals("chunked", record.storage_kind)
2788
 
        self.assertEquals("FOOBAR", record.get_bytes_as("fulltext"))
2789
 
        self.assertEquals(["FOO", "BAR"], record.get_bytes_as("chunked"))
 
2787
        self.assertEqual("chunked", record.storage_kind)
 
2788
        self.assertEqual("FOOBAR", record.get_bytes_as("fulltext"))
 
2789
        self.assertEqual(["FOO", "BAR"], record.get_bytes_as("chunked"))
2790
2790
 
2791
2791
    def test_get_record_stream_absent(self):
2792
2792
        it = self.texts.get_record_stream([("A",)], "unordered", True)
2793
2793
        record = it.next()
2794
 
        self.assertEquals("absent", record.storage_kind)
 
2794
        self.assertEqual("absent", record.storage_kind)
2795
2795
 
2796
2796
    def test_iter_lines_added_or_present_in_keys(self):
2797
2797
        self._lines["A"] = ["FOO", "BAR"]
2798
2798
        self._lines["B"] = ["HEY"]
2799
2799
        self._lines["C"] = ["Alberta"]
2800
2800
        it = self.texts.iter_lines_added_or_present_in_keys([("A",), ("B",)])
2801
 
        self.assertEquals(sorted([("FOO", "A"), ("BAR", "A"), ("HEY", "B")]),
 
2801
        self.assertEqual(sorted([("FOO", "A"), ("BAR", "A"), ("HEY", "B")]),
2802
2802
            sorted(list(it)))
2803
2803
 
2804
2804