def test_just_md5(self):
     # merge_file_lists copes with the omission of SHA1 or SHA256
     # hashes.
     files = [
         ('a', '1', 'd', 'e', 'foo.deb'), ('b', '2', 's', 'o', 'bar.dsc')]
     self.assertEqual(
         [("foo.deb", {'MD5': 'a'}, '1', 'd', 'e'),
          ("bar.dsc", {'MD5': 'b'}, '2', 's', 'o')],
          merge_file_lists(files, None, None))
 def test_differing_file_sizes_are_rejected(self):
     # merge_file_lists rejects Checksums-* fields which are present
     # but have a different set of filenames.
     files = [('a', '1', 'd', 'e', 'foo.deb')]
     sha1s = [('aa', '1', 'foo.deb')]
     sha1s_bad_size = [('aa', '2', 'foo.deb')]
     self.assertEqual(1, len(merge_file_lists(files, sha1s, None)))
     self.assertRaisesWithContent(
         UploadError, "Mismatch between Checksums-Sha1 and Files fields.",
         merge_file_lists, files, sha1s_bad_size, None)
 def test_all_hashes_for_dsc(self):
     # merge_file_lists in DSC mode returns a list of
     # (filename, {algo: hash}, size).
     files = [
         ('a', '1', 'foo.deb'), ('b', '2', 'bar.dsc')]
     checksums_sha1 = [('aa', '1', 'foo.deb'), ('bb', '2', 'bar.dsc')]
     checksums_sha256 = [('aaa', '1', 'foo.deb'), ('bbb', '2', 'bar.dsc')]
     self.assertEqual(
         [("foo.deb", {'MD5': 'a', 'SHA1': 'aa', 'SHA256': 'aaa'}, '1'),
          ("bar.dsc", {'MD5': 'b', 'SHA1': 'bb', 'SHA256': 'bbb'}, '2')],
          merge_file_lists(
              files, checksums_sha1, checksums_sha256, changes=False))
 def test_all_hashes(self):
     # merge_file_lists returns a list of
     # (filename, {algo: hash}, size, component_and_section, priority).
     files = [
         ('a', '1', 'd', 'e', 'foo.deb'), ('b', '2', 's', 'o', 'bar.dsc')]
     checksums_sha1 = [('aa', '1', 'foo.deb'), ('bb', '2', 'bar.dsc')]
     checksums_sha256 = [('aaa', '1', 'foo.deb'), ('bbb', '2', 'bar.dsc')]
     self.assertEqual(
         [("foo.deb",
           {'MD5': 'a', 'SHA1': 'aa', 'SHA256': 'aaa'}, '1', 'd', 'e'),
          ("bar.dsc",
           {'MD5': 'b', 'SHA1': 'bb', 'SHA256': 'bbb'}, '2', 's', 'o')],
          merge_file_lists(files, checksums_sha1, checksums_sha256))