t_pkg_depotd.py 文件源码

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

项目:solaris-ips 作者: oracle 项目源码 文件源码
def test_disable_ops(self):
                """Verify that disable-ops works as expected."""

                # For this disabled case, /catalog/1/ should return
                # a NOT_FOUND error.
                self.__dc.set_disable_ops(["catalog/1"])
                self.__dc.set_port(self.next_free_port)
                self.__dc.start()
                durl = self.__dc.get_depot_url()
                try:
                        urlopen("{0}/catalog/1/".format(durl))
                except HTTPError as e:
                        self.assertEqual(e.code, http_client.NOT_FOUND)
                self.__dc.stop()

                # For this disabled case, all /catalog/ operations should return
                # a NOT_FOUND error.
                self.__dc.set_disable_ops(["catalog"])
                self.__dc.set_port(self.next_free_port)
                self.__dc.start()
                durl = self.__dc.get_depot_url()
                for ver in (0, 1):
                        try:
                                urlopen("{0}/catalog/{1:d}/".format(durl, ver))
                        except HTTPError as e:
                                self.assertEqual(e.code, http_client.NOT_FOUND)
                self.__dc.stop()

                # In the normal case, /catalog/1/ should return
                # a FORBIDDEN error.
                self.__dc.unset_disable_ops()
                self.__dc.start()
                durl = self.__dc.get_depot_url()
                try:
                        urlopen("{0}/catalog/1/".format(durl))
                except HTTPError as e:
                        self.assertEqual(e.code, http_client.FORBIDDEN)
                self.__dc.stop()

                # A bogus operation should prevent the depot from starting.
                self.__dc.set_disable_ops(["no_such_op/0"])
                self.__dc.start_expected_fail()
                self.assertFalse(self.__dc.is_alive())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号