コード例 #1
0
 def setUp(self):
     self.ret_chn = ReturnChannel(stdout_callback, {})
     command_list = load_modules()
     self.conf_path = os.path.join(get_directory_of_current_module(self), CONF_FILE_LOCATION)
     self.ret_chn = ReturnChannel(stdout_callback, {})
     self.config = Config('help', '', command_list, [], self.ret_chn, 'shell')
     self.rest_client = RESTBase('sde', 'conf_name', self.config)
     self.config.import_custom_options()
     Config.parse_config_file(self.config, self.conf_path)
コード例 #2
0
class TestRestClient(unittest.TestCase):

    def setUp(self):
        self.ret_chn = ReturnChannel(stdout_callback, {})
        command_list = load_modules()
        self.conf_path = os.path.join(get_directory_of_current_module(self), CONF_FILE_LOCATION)
        self.ret_chn = ReturnChannel(stdout_callback, {})
        self.config = Config('help', '', command_list, [], self.ret_chn, 'shell')
        self.rest_client = RESTBase('sde', 'conf_name', self.config)
        self.config.import_custom_options()
        Config.parse_config_file(self.config, self.conf_path)

    def test_context_root_is_empty(self):
        self._check_context_root_matches_target('', '')

    def test_context_root_is_slash(self):
        self._check_context_root_matches_target('/', '')

    def test_context_root_is_notempty(self):
        self._check_context_root_matches_target('branch', '/branch')

    def _check_context_root_matches_target(self, context_root, target):
        self.rest_client.config['sde_context_root'] = context_root
        self.assertTrue(self.rest_client._get_context_root() == target, 'Expected an empty context root')