當前位置: 首頁>>代碼示例>>Python>>正文


Python YumImporter.validate_config方法代碼示例

本文整理匯總了Python中yum_importer.importer.YumImporter.validate_config方法的典型用法代碼示例。如果您正苦於以下問題:Python YumImporter.validate_config方法的具體用法?Python YumImporter.validate_config怎麽用?Python YumImporter.validate_config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yum_importer.importer.YumImporter的用法示例。


在下文中一共展示了YumImporter.validate_config方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_validate_config

# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import validate_config [as 別名]
    def test_validate_config(self):
        feed_url = "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/pulp_unittest/"
        importer = YumImporter()
        config = importer_mocks.get_basic_config(feed_url=feed_url)
        repo = mock.Mock(spec=Repository)
        state, msg = importer.validate_config(repo, config, [])
        self.assertTrue(state)

        # Test that an unknown argument in the config throws an error 
        # and the unknown arg is identified in the message
        config = importer_mocks.get_basic_config(feed_url=feed_url, bad_unknown_arg="blah")
        state, msg = importer.validate_config(repo, config, [])
        self.assertFalse(state)
        self.assertTrue("bad_unknown_arg" in msg)
開發者ID:jessegonzalez,項目名稱:pulp_rpm,代碼行數:16,代碼來源:test_rpms.py

示例2: TestValidateConfig

# 需要導入模塊: from yum_importer.importer import YumImporter [as 別名]
# 或者: from yum_importer.importer.YumImporter import validate_config [as 別名]
class TestValidateConfig(rpm_support_base.PulpRPMTests):

    def setUp(self):
        super(TestValidateConfig, self).setUp()
        self.temp_dir = tempfile.mkdtemp()
        self.repo = mock.Mock(spec=Repository)
        self.repo.working_dir = os.path.join(self.temp_dir, "repo_working_dir")
        os.makedirs(self.repo.working_dir)
        self.importer = YumImporter()
        self.init()

    def tearDown(self):
        super(TestValidateConfig, self).tearDown()
        shutil.rmtree(self.temp_dir)

    def init(self):
        self.data_dir = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "../data"))

    def test_config_feed_url(self):

        # test bad feed_url
        feed_url = "fake://example.redhat.com/"
        config = importer_mocks.get_basic_config(feed_url=feed_url)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertFalse(state)

        feed_url = "http://example.redhat.com/"
        config = importer_mocks.get_basic_config(feed_url=feed_url)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)

    def test_config_ssl_verify(self):
        feed_url = "http://example.redhat.com/"
        ssl_verify = "fake"
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_verify=ssl_verify)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertFalse(state)

        ssl_verify = True
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_verify=ssl_verify)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)


    def test_config_ssl_ca_cert(self):
        if not M2CRYPTO_HAS_CRL_SUPPORT:
            return
        feed_url = "http://example.redhat.com/"
        ssl_ca_cert = "fake_path_to_ca"
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_ca_cert=ssl_ca_cert)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertFalse(state)

        ssl_ca_cert = open(os.path.join(self.data_dir, "valid_ca.crt")).read()
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_ca_cert=ssl_ca_cert)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)

        ssl_ca_cert_filename = os.path.join(self.repo.working_dir, "ssl_ca_cert")
        self.assertTrue(os.path.exists(ssl_ca_cert_filename))
        ca_cert_data = open(ssl_ca_cert_filename).read()
        self.assertEqual(ca_cert_data, ssl_ca_cert)

    def test_config_ssl_client_cert(self):
        if not M2CRYPTO_HAS_CRL_SUPPORT:
            return
        feed_url = "http://example.redhat.com/"
        ssl_client_cert = "fake_path_to_client_cert"
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_client_cert=ssl_client_cert)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertFalse(state)

        ssl_client_cert = open(os.path.join(self.data_dir, "cert.crt")).read()
        config = importer_mocks.get_basic_config(feed_url=feed_url, ssl_client_cert=ssl_client_cert)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)
        
        ssl_client_cert_filename = os.path.join(self.repo.working_dir, "ssl_client_cert")
        self.assertTrue(os.path.exists(ssl_client_cert_filename))
        client_cert_data = open(ssl_client_cert_filename).read()
        self.assertEqual(client_cert_data, ssl_client_cert)

    def test_config_proxy_url(self):
        feed_url = "http://example.redhat.com/"
        proxy_url = "fake://proxy"
        config = importer_mocks.get_basic_config(feed_url=feed_url, proxy_url=proxy_url)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertFalse(state)

        proxy_url = "http://proxy"
        config = importer_mocks.get_basic_config(feed_url=feed_url, proxy_url=proxy_url)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)

    def test_config_proxy_port(self):
        config = importer_mocks.get_basic_config(proxy_port=100)
        state, msg = self.importer.validate_config(self.repo, config, [])
        self.assertTrue(state)

        config = importer_mocks.get_basic_config(proxy_port='port')
#.........這裏部分代碼省略.........
開發者ID:jessegonzalez,項目名稱:pulp_rpm,代碼行數:103,代碼來源:test_importer_validate_config.py


注:本文中的yum_importer.importer.YumImporter.validate_config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。