def test_should_load_configuration_file_when_no_properties_available(self, mock_load_configuration_file, mock_properties): mock_properties.return_value = None def mock_set_properties(): mock_properties.return_value = {self.mock_configuration_property: 12345} mock_load_configuration_file.side_effect = mock_set_properties ConfigurationProperty.__call__(self.mock_configuration_property) mock_load_configuration_file.assert_called_with()
def test_should_load_configuration_file_when_no_properties_available( self, mock_load_configuration_file, mock_properties): mock_properties.return_value = None def mock_set_properties(): mock_properties.return_value = { self.mock_configuration_property: 12345 } mock_load_configuration_file.side_effect = mock_set_properties ConfigurationProperty.__call__(self.mock_configuration_property) mock_load_configuration_file.assert_called_with()
def test_should_return_value_of_property_when_in_properties(self, mock_properties): mock_properties.return_value = {self.mock_configuration_property: 28374} actual = ConfigurationProperty.__call__(self.mock_configuration_property) self.assertEqual(28374, actual)
def test_should_return_value_of_property_when_in_properties( self, mock_properties): mock_properties.return_value = { self.mock_configuration_property: 28374 } actual = ConfigurationProperty.__call__( self.mock_configuration_property) self.assertEqual(28374, actual)
def test_should_log_given_configuration_properties_in_alphabetical_order( self): property_a = ConfigurationProperty(key='a_property', default=123) property_b = ConfigurationProperty(key='b_property', default=123) property_c = ConfigurationProperty(key='c_property', default=123) configuration = { property_a: 123, property_b: False, property_c: 'hello world' } log_configuration(self.mock_log, configuration, 'configuration_file.yaml') self.mock_log.assert_any_call('Loaded configuration file "%s"', 'configuration_file.yaml') self.mock_log.assert_any_call('Configuration property %s = "%s" (%s)', '"a_property"', 123, 'int') self.mock_log.assert_any_call('Configuration property %s = "%s" (%s)', '"b_property"', False, 'bool') self.mock_log.assert_any_call('Configuration property %s = "%s" (%s)', '"c_property"', 'hello world', 'str')
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ This module contains all configuration properties for yadt-config-rpm-maker. The configuration property values will be read from the configuration file. """ from config_rpm_maker.configuration import ConfigurationProperty get_config_viewer_host_directory = ConfigurationProperty( key='config_viewer_hosts_dir', default='/tmp') get_config_rpm_prefix = ConfigurationProperty(key='config_rpm_prefix', default='yadt-config-') get_custom_dns_search_list = ConfigurationProperty(key='custom_dns_searchlist', default=[]) get_error_log_directory = ConfigurationProperty(key='error_log_dir', default="") get_error_log_url = ConfigurationProperty(key='error_log_url', default='') get_log_format = ConfigurationProperty(key="log_format", default="[%(levelname)5s] %(message)s") get_log_level = ConfigurationProperty(key="log_level", default='DEBUG') get_max_failed_hosts = ConfigurationProperty(key='max_failed_hosts', default=3) get_max_file_size = ConfigurationProperty(key='max_file_size', default=100 * 1024) get_path_to_spec_file = ConfigurationProperty(key='path_to_spec_file', default='default.spec')
def setUp(self): self.configuration_property = ConfigurationProperty(key='property', default='default') self.mock_log = Mock()