def test_validate(self, mock_https, mock_http): # Setup all_mock_calls = (mock_http, mock_https) for x in all_mock_calls: x.return_value = True, None # Test c = PluginCallConfiguration({}, {}) result, msg = configuration.validate(c) # Verify self.assertTrue(result) self.assertTrue(msg is None) for x in all_mock_calls: x.assert_called_once_with(c)
def test_validate_with_failure(self, mock_https, mock_http): # Setup all_mock_calls = (mock_http, mock_https) for x in all_mock_calls: x.return_value = True, None all_mock_calls[0].return_value = False, 'foo' # Test c = PluginCallConfiguration({}, {}) result, msg = configuration.validate(c) # Verify self.assertTrue(not result) self.assertTrue(msg is not None) self.assertEqual(msg, 'foo') all_mock_calls[0].assert_called_once_with(c) for x in all_mock_calls[1:]: self.assertEqual(0, x.call_count)
def validate_config(self, repo, config, related_repos): config.default_config = configuration.DEFAULT_CONFIG return configuration.validate(config)