Exemplo n.º 1
0
    def test_computefilechecksum_for_empty_file(self):
        path = os.path.join(self.tmpdir, "empty_file")
        open(path, "w").close()

        # Default checksum (sha256)
        calculated = compute_file_checksum(path)
        self.assertEqual(calculated, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")

        # sha - Classical creterepo says sha, but means sha1 so expect the value for sha1
        calculated = compute_file_checksum(path, type="sha")
        self.assertEqual(calculated, "da39a3ee5e6b4b0d3255bfef95601890afd80709")

        # sha1
        calculated = compute_file_checksum(path, type="sha1")
        self.assertEqual(calculated, "da39a3ee5e6b4b0d3255bfef95601890afd80709")

        # sha224
        calculated = compute_file_checksum(path, type="sha224")
        self.assertEqual(calculated, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f")

        # sha512
        calculated = compute_file_checksum(path, type="sha512")
        self.assertEqual(calculated, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e")
Exemplo n.º 2
0
    def test_deltareposrecord_from_valid_deltarepo(self):
        rec = deltareposrecord_from_repopath(fixtures.DELTAREPO_01_02)

        # Check values parsed from repo's deltametadata.xml
        self.assertEqual(rec.location_base, None)
        self.assertEqual(rec.location_href, fixtures.DELTAREPO_01_02)
        self.assertEqual(rec.revision_src, "1378724582")
        self.assertEqual(rec.revision_dst, "1413550726")
        self.assertEqual(rec.contenthash_src, "4d1c9f8b7c442adb5f90fda368ec7eb267fa42759a5d125001585bc8928b3967")
        self.assertEqual(rec.contenthash_dst, "29ff875f99fe44a4b697ffe19bee5e874b5c61c5b0517f7f0772caae292b2bf7")
        self.assertEqual(rec.contenthash_type, "sha256")
        self.assertEqual(rec.timestamp_src, 1378724581)
        self.assertEqual(rec.timestamp_dst, 1413550726)

        # Check values calculated for repo's repomd.xml
        repomd_path = os.path.join(fixtures.DELTAREPO_01_02, "repodata", "repomd.xml")
        self.assertEqual(rec.repomd_timestamp, int(os.path.getmtime(repomd_path)))
        self.assertEqual(rec.repomd_size, os.path.getsize(repomd_path))
        checksumval = compute_file_checksum(repomd_path)
        self.assertEqual(rec.repomd_checksums, [("sha256", checksumval)])