当前位置: 首页>>代码示例>>Python>>正文


Python importer_mocks.get_basic_config函数代码示例

本文整理汇总了Python中pulp_rpm.devel.importer_mocks.get_basic_config函数的典型用法代码示例。如果您正苦于以下问题:Python get_basic_config函数的具体用法?Python get_basic_config怎么用?Python get_basic_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_basic_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_invalid_config

 def test_invalid_config(self):
     config = importer_mocks.get_basic_config(**{importer_constants.KEY_MAX_SPEED: -1.0,
                                                 importer_constants.KEY_FEED: 'http://test.com'})
     status, error_message = configuration.validate(config)
     self.assertTrue(status is False)
     self.assertEqual(error_message, 'The configuration parameter <max_speed> must be set to a positive '
                                     'numerical value, but is currently set to <-1.0>.')
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:7,代码来源:test_iso_importer_configuration.py

示例2: test_download_succeeded_honors_validate_units_set_true

    def test_download_succeeded_honors_validate_units_set_true(self, download_failed):
        """
        We have a setting that makes download validation optional. This test ensures that
        download_succeeded()
        honors that setting.
        """
        # In this config, we will set validate_units to False, which should make our
        # "wrong_checksum" OK
        config = importer_mocks.get_basic_config(
            **{importer_constants.KEY_FEED: 'http://fake.com/iso_feed/',
               importer_constants.KEY_VALIDATE: True})

        iso_sync_run = ISOSyncRun(self.sync_conduit, config)

        destination = os.path.join(self.temp_dir, 'test.txt')
        with open(destination, 'w') as test_file:
            test_file.write('Boring test data.')
        unit = MagicMock()
        unit.storage_path = destination
        iso = models.ISO('test.txt', 114, 'wrong checksum', unit)
        iso.url = 'http://fake.com'
        report = DownloadReport(iso.url, destination, iso)

        # Let's fake having downloaded the whole file
        iso.bytes_downloaded = iso.size
        report.bytes_downloaded = iso.size
        iso_sync_run.progress_report._state = SyncProgressReport.STATE_ISOS_IN_PROGRESS

        iso_sync_run.download_succeeded(report)

        # Because we fail validation, the save_unit step will not be called
        self.assertEqual(self.sync_conduit.save_unit.call_count, 0)
        # The download should be marked failed
        self.assertEqual(download_failed.call_count, 1)
        download_failed.assert_called_once_with(report)
开发者ID:hjensas,项目名称:pulp_rpm,代码行数:35,代码来源:test_sync.py

示例3: test_validate

 def test_validate(self):
     config = importer_mocks.get_basic_config(
         **{importer_constants.KEY_MAX_SPEED: 1.0, importer_constants.KEY_FEED: "http://test.com"}
     )
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py

示例4: test_validate_str

 def test_validate_str(self):
     parameters = {importer_constants.KEY_PROXY_PORT: '3128', importer_constants.KEY_PROXY_HOST: 'http://test.com',
                   importer_constants.KEY_FEED: 'http://test.com'}
     config = importer_mocks.get_basic_config(**parameters)
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:7,代码来源:test_iso_importer_configuration.py

示例5: test_upload_unit_validate_unset

    def test_upload_unit_validate_unset(self, remove, validate):
        """
        Assert correct behavior from upload_unit() when the validation setting is not set. This
        should default to validating the upload.
        """
        # Set up the test
        file_data = "This is a file.\n"
        working_dir = os.path.join(self.temp_dir, "working")
        os.mkdir(working_dir)
        pkg_dir = os.path.join(self.temp_dir, "content")
        os.mkdir(pkg_dir)
        repo = mock.MagicMock(spec=Repository)
        repo.working_dir = working_dir
        # Set the checksum incorrect. The upload should be unsuccessful since the default is to
        # validate
        unit_key = {"name": "test.iso", "size": 16, "checksum": "Wrong"}
        metadata = {}
        temp_file_location = os.path.join(self.temp_dir, "test.iso")
        with open(temp_file_location, "w") as temp_file:
            temp_file.write(file_data)
        sync_conduit = importer_mocks.get_sync_conduit(pkg_dir=pkg_dir)
        # validate isn't set, so default should happen
        config = importer_mocks.get_basic_config()

        # Run the upload. This should report a failure
        report = self.iso_importer.upload_unit(
            repo, ids.TYPE_ID_ISO, unit_key, metadata, temp_file_location, sync_conduit, config
        )

        self.assertEqual(report["success_flag"], False)
        self.assertEqual(
            report["summary"],
            (
                "Downloading <test.iso> failed checksum validation. The manifest specified the "
                "checksum to be Wrong, but it was "
                "f02d5a72cd2d57fa802840a76b44c6c6920a8b8e6b90b20e26c03876275069e0."
            ),
        )

        # The conduit's init_unit method should have been called
        expected_rel_path = os.path.join(
            unit_key["name"], unit_key["checksum"], str(unit_key["size"]), unit_key["name"]
        )
        modified_metadata = metadata.copy()
        modified_metadata[server_constants.PULP_USER_METADATA_FIELDNAME] = {}
        sync_conduit.init_unit.assert_called_once_with(ids.TYPE_ID_ISO, unit_key, modified_metadata, expected_rel_path)

        # The file should have been moved to its final destination
        self.assertFalse(os.path.exists(temp_file_location))
        would_be_destination = os.path.join(pkg_dir, expected_rel_path)
        self.assertFalse(os.path.exists(would_be_destination))
        # The file should have been removed
        remove.assert_called_once_with(would_be_destination)

        # validate() should have been called with the full_validation=True flag
        iso = validate.mock_calls[0][1][0]
        validate.assert_called_once_with(iso, full_validation=True)

        # The conduit's save_unit method should have been called
        self.assertEqual(sync_conduit.save_unit.call_count, 0)
开发者ID:goosemania,项目名称:pulp_rpm,代码行数:60,代码来源:test_importer.py

示例6: test_validate

 def test_validate(self):
     config = importer_mocks.get_basic_config(
         **{importer_constants.KEY_PROXY_HOST: 'http://fake.com/',
            importer_constants.KEY_FEED: 'http://test.com'})
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:AndreaGiardini,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py

示例7: test_required_when_other_parameters_are_present

 def test_required_when_other_parameters_are_present(self):
     for parameters in [
         {
             importer_constants.KEY_PROXY_PASS: "flock_of_seagulls",
             importer_constants.KEY_PROXY_USER: "big_kahuna_burger",
             importer_constants.KEY_FEED: "http://fake.com",
         },
         {importer_constants.KEY_PROXY_PORT: "3037", importer_constants.KEY_FEED: "http://fake.com"},
     ]:
         # Each of the above configurations should cause the validator to complain about the
         # proxy_url
         # missing
         config = importer_mocks.get_basic_config(**parameters)
         status, error_message = configuration.validate(config)
         self.assertTrue(status is False)
         expected_message = (
             "The configuration parameter <%(proxy_host)s> is required when any of the "
             "following "
             "other parameters are defined: %(proxy_pass)s, %(proxy_port)s, %(proxy_user)s."
         )
         expected_message = expected_message % {
             "proxy_pass": importer_constants.KEY_PROXY_PASS,
             "proxy_user": importer_constants.KEY_PROXY_USER,
             "proxy_port": importer_constants.KEY_PROXY_PORT,
             "proxy_host": importer_constants.KEY_PROXY_HOST,
         }
         self.assertEqual(error_message, expected_message)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:27,代码来源:test_configuration.py

示例8: test_client_key_requires_client_cert

 def test_client_key_requires_client_cert(self):
     config = importer_mocks.get_basic_config(**{importer_constants.KEY_SSL_CLIENT_KEY: 'Client Key!',
                                                 importer_constants.KEY_FEED: 'http://test.com'})
     status, error_message = configuration.validate(config)
     self.assertTrue(status is False)
     self.assertEqual(error_message, 'The configuration parameter <ssl_client_key> requires the '
                                     '<ssl_client_cert> parameter to also be set.')
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:7,代码来源:test_iso_importer_configuration.py

示例9: test_required_when_other_parameters_are_present

 def test_required_when_other_parameters_are_present(self):
     for parameters in [
         {importer_constants.KEY_MAX_SPEED: '1024'}, {importer_constants.KEY_MAX_DOWNLOADS: 2},
         {importer_constants.KEY_PROXY_PASS: 'flock_of_seagulls',
          importer_constants.KEY_PROXY_USER: 'big_kahuna_burger',
          importer_constants.KEY_PROXY_HOST: 'http://test.com'},
         {importer_constants.KEY_PROXY_HOST: 'http://test.com', importer_constants.KEY_PROXY_PORT: '3037'},
         {importer_constants.KEY_PROXY_HOST: 'http://test.com'},
         {importer_constants.KEY_UNITS_REMOVE_MISSING: True},
         {importer_constants.KEY_SSL_CA_CERT: 'cert'},
         {importer_constants.KEY_SSL_CLIENT_CERT: 'cert'},
         {importer_constants.KEY_SSL_CLIENT_CERT: 'cert', importer_constants.KEY_SSL_CLIENT_KEY: 'key'},
         {importer_constants.KEY_VALIDATE: True}]:
             # Each of the above configurations should cause the validator to complain about the feed_url
             # missing
             config = importer_mocks.get_basic_config(**parameters)
             status, error_message = configuration.validate(config)
             self.assertTrue(status is False)
             self.assertEqual(
                 error_message,
                 'The configuration parameter <%(feed)s> is required when any of the following other '
                 'parameters are defined: %(max_speed)s, %(num_threads)s, %(proxy_pass)s, %(proxy_port)s, '
                 '%(proxy_host)s, %(proxy_user)s, %(remove_missing_units)s, %(ssl_ca_cert)s, '
                 '%(ssl_client_cert)s, %(ssl_client_key)s, %(validate_units)s.' % {
                     'feed': importer_constants.KEY_FEED, 'max_speed': importer_constants.KEY_MAX_SPEED,
                     'num_threads': importer_constants.KEY_MAX_DOWNLOADS,
                     'proxy_pass': importer_constants.KEY_PROXY_PASS,
                     'proxy_port': importer_constants.KEY_PROXY_PORT,
                     'proxy_host': importer_constants.KEY_PROXY_HOST,
                     'proxy_user': importer_constants.KEY_PROXY_USER,
                     'remove_missing_units': importer_constants.KEY_UNITS_REMOVE_MISSING,
                     'ssl_ca_cert': importer_constants.KEY_SSL_CA_CERT,
                     'ssl_client_cert': importer_constants.KEY_SSL_CLIENT_CERT,
                     'ssl_client_key': importer_constants.KEY_SSL_CLIENT_KEY,
                     'validate_units': importer_constants.KEY_VALIDATE})
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:35,代码来源:test_iso_importer_configuration.py

示例10: test_valid_config

 def test_valid_config(self):
     config = importer_mocks.get_basic_config(
         **{importer_constants.KEY_UNITS_REMOVE_MISSING: True, importer_constants.KEY_FEED: "http://feed.com"}
     )
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py

示例11: test_client_cert_is_non_string

 def test_client_cert_is_non_string(self):
     config = importer_mocks.get_basic_config(**{importer_constants.KEY_SSL_CLIENT_CERT: 8,
                                                 importer_constants.KEY_FEED: 'http://test.com'})
     status, error_message = configuration.validate(config)
     self.assertTrue(status is False)
     self.assertEqual(error_message, "The configuration parameter <ssl_client_cert> should be a string, "
                                     "but it was <type 'int'>.")
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:7,代码来源:test_iso_importer_configuration.py

示例12: test_string_true

 def test_string_true(self):
     config = importer_mocks.get_basic_config(
         **{importer_constants.KEY_VALIDATE: "true", importer_constants.KEY_FEED: "http://feed.com"}
     )
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py

示例13: test_password_is_non_string

 def test_password_is_non_string(self):
     parameters = {importer_constants.KEY_PROXY_PASS: 7, importer_constants.KEY_PROXY_USER: "the_dude",
                   importer_constants.KEY_FEED: 'http://test.com'}
     config = importer_mocks.get_basic_config(**parameters)
     status, error_message = configuration.validate(config)
     self.assertTrue(status is False)
     self.assertEqual(error_message, "The configuration parameter <proxy_password> should be a string, "
                                     "but it was <type 'int'>.")
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:8,代码来源:test_iso_importer_configuration.py

示例14: test_validate

 def test_validate(self):
     params = {importer_constants.KEY_PROXY_PASS: 'duderino', importer_constants.KEY_PROXY_USER: 'the_dude',
               importer_constants.KEY_PROXY_HOST: 'http://fake.com/',
               importer_constants.KEY_FEED: 'http://test.com'}
     config = importer_mocks.get_basic_config(**params)
     status, error_message = configuration.validate(config)
     self.assertTrue(status is True)
     self.assertEqual(error_message, None)
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:8,代码来源:test_iso_importer_configuration.py

示例15: test_zero

 def test_zero(self):
     parameters = {importer_constants.KEY_PROXY_PORT: 0, importer_constants.KEY_PROXY_HOST: 'http://test.com',
                   importer_constants.KEY_FEED: 'http://test.com'}
     config = importer_mocks.get_basic_config(**parameters)
     status, error_message = configuration.validate(config)
     self.assertTrue(status is False)
     self.assertEqual(error_message, 'The configuration parameter <proxy_port> must be set to a positive '
                                     'integer, but is currently set to <0>.')
开发者ID:pombredanne,项目名称:rcm-pulp-rpm,代码行数:8,代码来源:test_iso_importer_configuration.py


注:本文中的pulp_rpm.devel.importer_mocks.get_basic_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。