~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: INADA Naoki
  • Date: 2011-05-17 00:45:09 UTC
  • mfrom: (5875 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5891.
  • Revision ID: songofacandy@gmail.com-20110517004509-q58negjbdjh7t6u1
mergeĀ fromĀ lp:bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
732
732
 
733
733
    def make_multiple_records(self):
734
734
        """Create the content for multiple records."""
735
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
735
        sha1sum = osutils.sha_string('foo\nbar\n')
736
736
        total_txt = []
737
737
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
738
738
                                        'foo\n'
741
741
                                        % (sha1sum,))
742
742
        record_1 = (0, len(gz_txt), sha1sum)
743
743
        total_txt.append(gz_txt)
744
 
        sha1sum = osutils.sha('baz\n').hexdigest()
 
744
        sha1sum = osutils.sha_string('baz\n')
745
745
        gz_txt = self.create_gz_content('version rev-id-2 1 %s\n'
746
746
                                        'baz\n'
747
747
                                        'end rev-id-2\n'
751
751
        return total_txt, record_1, record_2
752
752
 
753
753
    def test_valid_knit_data(self):
754
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
754
        sha1sum = osutils.sha_string('foo\nbar\n')
755
755
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
756
756
                                        'foo\n'
757
757
                                        'bar\n'
788
788
                         raw_contents)
789
789
 
790
790
    def test_not_enough_lines(self):
791
 
        sha1sum = osutils.sha('foo\n').hexdigest()
 
791
        sha1sum = osutils.sha_string('foo\n')
792
792
        # record says 2 lines data says 1
793
793
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
794
794
                                        'foo\n'
806
806
        self.assertEqual([(('rev-id-1',),  gz_txt, sha1sum)], raw_contents)
807
807
 
808
808
    def test_too_many_lines(self):
809
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
809
        sha1sum = osutils.sha_string('foo\nbar\n')
810
810
        # record says 1 lines data says 2
811
811
        gz_txt = self.create_gz_content('version rev-id-1 1 %s\n'
812
812
                                        'foo\n'
825
825
        self.assertEqual([(('rev-id-1',), gz_txt, sha1sum)], raw_contents)
826
826
 
827
827
    def test_mismatched_version_id(self):
828
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
828
        sha1sum = osutils.sha_string('foo\nbar\n')
829
829
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
830
830
                                        'foo\n'
831
831
                                        'bar\n'
844
844
            knit._read_records_iter_raw(records))
845
845
 
846
846
    def test_uncompressed_data(self):
847
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
847
        sha1sum = osutils.sha_string('foo\nbar\n')
848
848
        txt = ('version rev-id-1 2 %s\n'
849
849
               'foo\n'
850
850
               'bar\n'
864
864
            knit._read_records_iter_raw(records))
865
865
 
866
866
    def test_corrupted_data(self):
867
 
        sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
867
        sha1sum = osutils.sha_string('foo\nbar\n')
868
868
        gz_txt = self.create_gz_content('version rev-id-1 2 %s\n'
869
869
                                        'foo\n'
870
870
                                        'bar\n'
1192
1192
            self.assertRaises(errors.KnitCorrupt, index.keys)
1193
1193
        except TypeError, e:
1194
1194
            if (str(e) == ('exceptions must be strings, classes, or instances,'
1195
 
                           ' not exceptions.IndexError')
1196
 
                and sys.version_info[0:2] >= (2,5)):
 
1195
                           ' not exceptions.IndexError')):
1197
1196
                self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
1198
1197
                                  ' raising new style exceptions with python'
1199
1198
                                  ' >=2.5')
1212
1211
            self.assertRaises(errors.KnitCorrupt, index.keys)
1213
1212
        except TypeError, e:
1214
1213
            if (str(e) == ('exceptions must be strings, classes, or instances,'
1215
 
                           ' not exceptions.ValueError')
1216
 
                and sys.version_info[0:2] >= (2,5)):
 
1214
                           ' not exceptions.ValueError')):
1217
1215
                self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
1218
1216
                                  ' raising new style exceptions with python'
1219
1217
                                  ' >=2.5')
1232
1230
            self.assertRaises(errors.KnitCorrupt, index.keys)
1233
1231
        except TypeError, e:
1234
1232
            if (str(e) == ('exceptions must be strings, classes, or instances,'
1235
 
                           ' not exceptions.ValueError')
1236
 
                and sys.version_info[0:2] >= (2,5)):
 
1233
                           ' not exceptions.ValueError')):
1237
1234
                self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
1238
1235
                                  ' raising new style exceptions with python'
1239
1236
                                  ' >=2.5')
1250
1247
            self.assertRaises(errors.KnitCorrupt, index.keys)
1251
1248
        except TypeError, e:
1252
1249
            if (str(e) == ('exceptions must be strings, classes, or instances,'
1253
 
                           ' not exceptions.ValueError')
1254
 
                and sys.version_info[0:2] >= (2,5)):
 
1250
                           ' not exceptions.ValueError')):
1255
1251
                self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
1256
1252
                                  ' raising new style exceptions with python'
1257
1253
                                  ' >=2.5')
1268
1264
            self.assertRaises(errors.KnitCorrupt, index.keys)
1269
1265
        except TypeError, e:
1270
1266
            if (str(e) == ('exceptions must be strings, classes, or instances,'
1271
 
                           ' not exceptions.ValueError')
1272
 
                and sys.version_info[0:2] >= (2,5)):
 
1267
                           ' not exceptions.ValueError')):
1273
1268
                self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
1274
1269
                                  ' raising new style exceptions with python'
1275
1270
                                  ' >=2.5')
2444
2439
        key_basis = ('bar',)
2445
2440
        key_missing = ('missing',)
2446
2441
        test.add_lines(key, (), ['foo\n'])
2447
 
        key_sha1sum = osutils.sha('foo\n').hexdigest()
 
2442
        key_sha1sum = osutils.sha_string('foo\n')
2448
2443
        sha1s = test.get_sha1s([key])
2449
2444
        self.assertEqual({key: key_sha1sum}, sha1s)
2450
2445
        self.assertEqual([], basis.calls)
2452
2447
        # directly (rather than via text reconstruction) so that remote servers
2453
2448
        # etc don't have to answer with full content.
2454
2449
        basis.add_lines(key_basis, (), ['foo\n', 'bar\n'])
2455
 
        basis_sha1sum = osutils.sha('foo\nbar\n').hexdigest()
 
2450
        basis_sha1sum = osutils.sha_string('foo\nbar\n')
2456
2451
        basis.calls = []
2457
2452
        sha1s = test.get_sha1s([key, key_missing, key_basis])
2458
2453
        self.assertEqual({key: key_sha1sum,