本文整理汇总了Python中pulp_rpm.plugins.importers.iso.configuration.validate函数的典型用法代码示例。如果您正苦于以下问题:Python validate函数的具体用法?Python validate怎么用?Python validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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:asmacdo,项目名称:pulp_rpm,代码行数:35,代码来源:test_configuration.py
示例2: 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:asmacdo,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.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:asmacdo,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py
示例5: 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:asmacdo,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py
示例6: 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:asmacdo,项目名称:pulp_rpm,代码行数:7,代码来源:test_configuration.py
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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:asmacdo,项目名称:pulp_rpm,代码行数:8,代码来源:test_configuration.py
示例12: 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:asmacdo,项目名称:pulp_rpm,代码行数:8,代码来源: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:asmacdo,项目名称:pulp_rpm,代码行数:8,代码来源:test_configuration.py
示例14: test_url_is_non_string
def test_url_is_non_string(self):
config = importer_mocks.get_basic_config(**{importer_constants.KEY_PROXY_HOST: 7,
importer_constants.KEY_FEED: 'http://test.com'})
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = ("The configuration parameter <%(proxy_host)s> should be a string, but it was "
"<type 'int'>.")
expected_message = expected_message % {'proxy_host': importer_constants.KEY_PROXY_HOST}
self.assertEqual(error_message, expected_message)
开发者ID:asmacdo,项目名称:pulp_rpm,代码行数:9,代码来源:test_configuration.py
示例15: test_invalid_config
def test_invalid_config(self):
config = importer_mocks.get_basic_config(**{importer_constants.KEY_VALIDATE: 1,
importer_constants.KEY_FEED: 'http://feed.com'})
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = ('The configuration parameter <%(validate)s> may only be set to a '
'boolean value, but is currently set to <1>.')
expected_message = expected_message % {'validate': importer_constants.KEY_VALIDATE}
self.assertEqual(error_message, expected_message)
开发者ID:AndreaGiardini,项目名称:pulp_rpm,代码行数:9,代码来源:test_configuration.py
示例16: test_username_is_non_string
def test_username_is_non_string(self):
parameters = {importer_constants.KEY_PROXY_PASS: 'bowling', importer_constants.KEY_PROXY_USER: 185,
importer_constants.KEY_PROXY_HOST: 'http://test.com',
importer_constants.KEY_FEED: 'http://test2.com'}
config = importer_mocks.get_basic_config(**parameters)
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = ("The configuration parameter <%(proxy_user)s> should be a string, but it was "
"<type 'int'>.")
expected_message = expected_message % {'proxy_user': importer_constants.KEY_PROXY_USER}
self.assertEqual(error_message, expected_message)
开发者ID:asmacdo,项目名称:pulp_rpm,代码行数:11,代码来源:test_configuration.py
示例17: test_username_requires_password
def test_username_requires_password(self):
parameters = {importer_constants.KEY_PROXY_USER: 'the_dude', importer_constants.KEY_FEED: 'http://fake.com',
importer_constants.KEY_PROXY_HOST: 'http://fake.com'}
config = importer_mocks.get_basic_config(**parameters)
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = ('The configuration parameter <%(proxy_user)s> requires the '
'<%(proxy_pass)s> parameter to also be set.')
expected_message = expected_message % {'proxy_user': importer_constants.KEY_PROXY_USER,
'proxy_pass': importer_constants.KEY_PROXY_PASS}
self.assertEqual(error_message, expected_message)
开发者ID:asmacdo,项目名称:pulp_rpm,代码行数:11,代码来源:test_configuration.py
示例18: test_float_str
def test_float_str(self):
config = importer_mocks.get_basic_config(
**{importer_constants.KEY_MAX_DOWNLOADS: "%s" % math.e, importer_constants.KEY_FEED: "http://test.com"}
)
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = (
"The configuration parameter <%(num_threads)s> must be set to a positive "
"integer, but is currently set to <%(e)s>."
)
expected_message = expected_message % {"num_threads": importer_constants.KEY_MAX_DOWNLOADS, "e": math.e}
self.assertEqual(error_message, expected_message)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:12,代码来源:test_configuration.py
示例19: test_invalid_config
def test_invalid_config(self):
config = importer_mocks.get_basic_config(
**{
importer_constants.KEY_FEED: "http://test.com/feed",
importer_constants.KEY_MAX_SPEED: "A Thousand",
importer_constants.KEY_MAX_DOWNLOADS: 7,
}
)
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 <A Thousand>.",
)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:15,代码来源:test_configuration.py
示例20: test_username_requires_password
def test_username_requires_password(self):
parameters = {
importer_constants.KEY_PROXY_USER: "the_dude",
importer_constants.KEY_FEED: "http://fake.com",
importer_constants.KEY_PROXY_HOST: "http://fake.com",
}
config = importer_mocks.get_basic_config(**parameters)
status, error_message = configuration.validate(config)
self.assertTrue(status is False)
expected_message = (
"The configuration parameter <%(proxy_user)s> requires the " "<%(proxy_pass)s> parameter to also be set."
)
expected_message = expected_message % {
"proxy_user": importer_constants.KEY_PROXY_USER,
"proxy_pass": importer_constants.KEY_PROXY_PASS,
}
self.assertEqual(error_message, expected_message)
开发者ID:pcreech,项目名称:pulp_rpm,代码行数:17,代码来源:test_configuration.py
注:本文中的pulp_rpm.plugins.importers.iso.configuration.validate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论