Skip to content

Commit

Permalink
Transfers: Fix unit tests when there is no policy section. rucio#570
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Feb 7, 2018
1 parent ab26e7b commit 6494276
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/rucio/common/config.py
Expand Up @@ -35,6 +35,9 @@ def config_has_section(section):
"""Indicates whether the named section is present in the configuration. The DEFAULT section is not acknowledged.)"""
return __CONFIG.has_section(section)

def config_add_section(section):
"""Add a new section to the configuration object. Throws DuplicateSectionError if it already exists."""
return __CONFIG.add_section(section)

def config_get_int(section, option):
"""Return the integer value for a given option in a section"""
Expand Down
6 changes: 4 additions & 2 deletions lib/rucio/tests/test_rse_lfn2path.py
Expand Up @@ -8,7 +8,7 @@
- Brian Bockelman, <bbockelm@cse.unl.edu>, 2018
'''

from ConfigParser import NoOptionError
from ConfigParser import NoOptionError, NoSectionError

from nose.tools import assert_equal

Expand Down Expand Up @@ -111,6 +111,8 @@ def rse_algorithm(scope, name, rse, rse_attrs, proto_attrs):

def test_module_load(self):
"""LFN2PFN: Test ability to provide LFN2PFN functions via module (Success)"""
if not config.config_has_section('policy'):
config.config_add_section('policy')
config.config_set('policy', 'lfn2pfn_module', 'rucio.tests.lfn2pfn_module_test')
RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access
self.rse_attributes['lfn2pfn_algorithm'] = 'lfn2pfn_module_algorithm'
Expand All @@ -121,7 +123,7 @@ def test_config_default_override(self):
"""LFN2PFN: Test override of default LFN2PFN algorithm via config (Success)"""
try:
orig_value = config.config_get('policy', 'lfn2pfn_algorithm_default')
except NoOptionError:
except (NoOptionError, NoSectionError):
orig_value = None

def static_test(scope, name, rse, rse_attrs, proto_attrs):
Expand Down

0 comments on commit 6494276

Please sign in to comment.