def test_csv_values_multikey_invalid_server_value(self, out_mock): """ test case globale: backup_options = concurrent_backup server: backup_options = exclusive_backup, none_of_your_business risultato = backup_options = concurrent_backup the 'none_of_your_business' value on server section invalidates the whole csv string, because is not an allowed value of the BackupOptions class. We expect to fallback to the global 'concurrent_backup' value. """ # build a string with a wrong value wrong_parameters = "%s, %s" % (BackupOptions.EXCLUSIVE_BACKUP, 'none_of_your_business') # add backup_options to minimal configuration string c = build_config_from_dicts( {'backup_options': BackupOptions.CONCURRENT_BACKUP}, {'backup_options': wrong_parameters}) main = c.get_server('main') # create the expected dictionary expected = dict(config=c) expected.update(MINIMAL_CONFIG_MAIN) # override the backup_options value in the expected dictionary expected['backup_options'] = BackupOptions( BackupOptions.CONCURRENT_BACKUP, "", "") assert main.__dict__ == expected # use the mocked output class to verify the presence of the warning # for a bad configuration parameter out_mock.warning.assert_called_with("Invalid configuration value '%s' " "for key %s in %s: %s", None, 'backup_options', '[main] section', mock.ANY)
def test_csv_values_invalid_server_value(self, out_mock): """ test case global: backup_options = exclusive_backup server: backup_options = none_of_your_business result = backup_options = exclusive_backup The 'none_of_your_business' value on server section, is not an allowed value for the BackupOptions class, We expect to the config builder to fallback to the global 'exclusive_backup' value """ # add backup_options to minimal configuration string c = build_config_from_dicts( {'backup_options': BackupOptions.EXCLUSIVE_BACKUP}, {'backup_options': 'none_of_your_business'}) main = c.get_server('main') # create the expected dictionary expected = dict(config=c) expected.update(MINIMAL_CONFIG_MAIN) assert main.__dict__ == expected # use the mocked output class to verify the presence of the warning # for a bad configuration parameter out_mock.warning.assert_called_with("Invalid configuration value '%s' " "for key %s in %s: %s", None, 'backup_options', '[main] section', mock.ANY)
def test_csv_values_global_conflict(self, out_mock): """ test case global value: backup_options = exclusive_backup, concurrent_backup server value: backup_options = expected: backup_options = exclusive_backup Empty value is not allowed in BackupOptions class, so we expect the configuration parser to fall back to the global value. The global backup_options holds conflicting parameters, so we expect the config builder to fall back to ignore de directive. """ # build a string with conflicting values conflict = "%s, %s" % (BackupOptions.EXCLUSIVE_BACKUP, BackupOptions.CONCURRENT_BACKUP) # add backup_options to minimal configuration string c = build_config_from_dicts( {'backup_options': conflict}, None) main = c.get_server('main') # create the expected dictionary expected = dict(config=c) expected.update(MINIMAL_CONFIG_MAIN) assert main.__dict__ == expected # use the mocked output class to verify the presence of the warning # for a bad configuration parameter out_mock.warning.assert_called_with("Invalid configuration value '%s' " "for key %s in %s: %s", None, 'backup_options', '[barman] section', mock.ANY)
def test_csv_values_global_concurrent(self): """ test case global value: backup_options = concurrent_backup expected: backup_options = concurrent_backup Simple test for concurrent_backup option parsing """ # add backup_options to minimal configuration string c = build_config_from_dicts( {'backup_options': BackupOptions.CONCURRENT_BACKUP}, None) main = c.get_server('main') expected = dict(config=c) expected.update(MINIMAL_CONFIG_MAIN) # override the backup_options value in the expected dictionary expected['backup_options'] = BackupOptions( BackupOptions.CONCURRENT_BACKUP, "", "") assert main.__dict__ == expected
def test_csv_values_global_exclusive(self): """ test case global value: backup_options = exclusive_backup server value: backup_options = expected: backup_options = exclusive_backup Empty value is not allowed in BackupOptions class, so we expect the configuration parser to fall back to the global value. """ # add backup_options configuration to minimal configuration string c = build_config_from_dicts( {'backup_options': BackupOptions.EXCLUSIVE_BACKUP}, {'backup_options': ''}) main = c.get_server('main') # create the expected dictionary expected = dict(config=c) expected.update(MINIMAL_CONFIG_MAIN) assert main.__dict__ == expected
def test_invalid_option_output(self, out_mock): """ Test the config behavior with unknown options """ # build a configuration with a a server and a global unknown vale. then # add them to the minimal configuration. c = build_config_from_dicts( {'test_global_option': 'invalid_value'}, {'test_server_option': 'invalid_value'}) c.validate_global_config() # use the mocked output class to verify the presence of the warning # for a unknown configuration parameter in the barman subsection out_mock.warning.assert_called_with( 'Invalid configuration option "%s" in [%s] section.', 'test_global_option', 'barman') #parse main section c.get_server('main') # use the mocked output class to verify the presence of the warning # for a unknown configuration parameter in the server subsection out_mock.warning.assert_called_with( 'Invalid configuration option "%s" in [%s] section.', 'test_server_option', 'main')