本文整理汇总了Python中pulp_rpm.plugins.importers.iso.configuration.validate函数的典型用法代码示例。如果您正苦于以下问题:Python validate函数的具体用法?Python validate怎么用?Python validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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})
示例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>.')
示例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)
示例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)
示例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'>.")
示例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.')
示例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)
示例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)
示例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)
示例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)
示例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)
示例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>.')
示例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'>.")
示例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)
示例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)