def test_config_bad_urls(self, mock_input, mock_load_config, mock_save_config):
test_urls = [
'foo.com',
'ftp://foo.com',
'blah://bar.com',
'http://foo.bar.com/baz',
]
# test general URL setting -- result should match initial state
mock_load_config.return_value = {}
initial_url = command.get_registry_url()
for test_url in test_urls:
mock_input.return_value = test_url
with assertRaisesRegex(self, command.CommandException, 'Invalid URL'):
command.config()
assert mock_input.called
mock_input.reset_mock()
mock_save_config.assert_not_called()
assert command.get_registry_url() == initial_url
评论列表
文章目录