test_install.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:quilt 作者: quiltdata 项目源码 文件源码
def test_bad_contents_hash(self):
        """
        Test that a package with a bad contents hash fails installation.
        """
        tabledata = b'Bad package'
        h = hashlib.new(HASH_TYPE)
        h.update(tabledata)
        obj_hash = h.hexdigest()
        contents = GroupNode(dict(
            foo=GroupNode(dict(
                bar=TableNode([obj_hash], PackageFormat.default.value)
            ))
        ))
        contents_hash = 'e867010701edc0b1c8be177e02a93aa3cb1342bb1123046e1f6b40e428c6048e'

        self._mock_tag('foo/bar', 'latest', contents_hash)
        self._mock_package('foo/bar', contents_hash, '', contents, [obj_hash])

        with assertRaisesRegex(self, command.CommandException, "Mismatched hash"):
            command.install('foo/bar')

        assert not os.path.exists(os.path.join(self._store_dir, 'foo/bar.json'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号