def normal_test(self): plugin = self.create_plugins() mod_name = plugin[0] section_name = 'temporary' cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), '[{0}]'.format(section_name), 'module = {0}'.format(mod_name), ) cfg_reader = ConfigReader(infile=cfg_lines) spec_lines = cfg_reader._get_raw_specs(cfg_reader.config) spec_lines = spec_lines[mod_name] spec = cfg_reader._configspec_factory( '{0}'.format(section_name), mod_name, spec_lines, ) ok_( section_name in spec, msg='Failed creation spec(for validation)' )
def not_implement_validator_test(self): cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), ) plugin_lines = ( 'class ConcreteJob(object):\n', ' pass\n', 'class InValidValidator(object):\n', ' pass\n', ) plugin = tempfile.NamedTemporaryFile( dir=self.tmp_dir, suffix='.py' ) plugin.writelines(plugin_lines) plugin.seek(0) cfg_reader = ConfigReader(infile=cfg_lines) modules = cfg_reader._get_modules() check_value = os.path.split(plugin.name)[1] check_value = check_value.split('.')[0] assert_false( check_value in modules, msg='{0}'.format(modules) )
def extend_module_dir_test(self): plugin = self.create_plugins() check_value = plugin[0] cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), ) cfg_reader = ConfigReader(infile=cfg_lines) modules = cfg_reader._get_modules() ok_(check_value in modules, msg='{0}'.format(modules))
def normal_test(self): plugin = self.create_plugins() check_value = plugin[0] cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), '[temporary]', 'module = {0}'.format(check_value), ) cfg_reader = ConfigReader(infile=cfg_lines) raw_specs = cfg_reader._get_raw_specs(cfg_reader.config) ok_(check_value in raw_specs, msg='ConfigReader has {0} as specs'.format(raw_specs))
def extend_module_dir_test(self): plugin = self.create_plugins() check_value = plugin[0] cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), ) cfg_reader = ConfigReader(infile=cfg_lines) modules = cfg_reader._get_modules() ok_( check_value in modules, msg='{0}'.format(modules) )
def normal_test(self): plugin = self.create_plugins() check_value = plugin[0] cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), '[temporary]', 'module = {0}'.format(check_value), ) cfg_reader = ConfigReader(infile=cfg_lines) raw_specs = cfg_reader._get_raw_specs(cfg_reader.config) ok_( check_value in raw_specs, msg='ConfigReader has {0} as specs'.format(raw_specs) )
def missing_module_value_test(self): """ be specified 'module' value in config file. """ cfg_lines = ( '[global]', '', '[for_test]', '', ) ok_(ConfigReader(infile=cfg_lines))
def not_implement_validator_test(self): cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), ) plugin_lines = ( 'class ConcreteJob(object):\n', ' pass\n', 'class InValidValidator(object):\n', ' pass\n', ) plugin = tempfile.NamedTemporaryFile(dir=self.tmp_dir, suffix='.py') plugin.writelines(plugin_lines) plugin.seek(0) cfg_reader = ConfigReader(infile=cfg_lines) modules = cfg_reader._get_modules() check_value = os.path.split(plugin.name)[1] check_value = check_value.split('.')[0] assert_false(check_value in modules, msg='{0}'.format(modules))
def normal_test(self): plugin = self.create_plugins() mod_name = plugin[0] section_name = 'temporary' cfg_lines = ( '[global]', 'module_dir = {0}'.format(self.tmp_dir), '[{0}]'.format(section_name), 'module = {0}'.format(mod_name), ) cfg_reader = ConfigReader(infile=cfg_lines) spec_lines = cfg_reader._get_raw_specs(cfg_reader.config) spec_lines = spec_lines[mod_name] spec = cfg_reader._configspec_factory( '{0}'.format(section_name), mod_name, spec_lines, ) ok_(section_name in spec, msg='Failed creation spec(for validation)')
def normal_test(self): """ Create temporary plugin and register it as jobs. """ plugin = self.create_plugins() check_value = plugin[0] cfg_lines = ('[global]', 'module_dir = {0}'.format(self.tmp_dir), '[temporary]', 'module = {0}'.format(check_value)) observer = JobObserver() cfg_reader = ConfigReader(infile=cfg_lines, observers=observer) ok_(check_value in observer.jobs, msg='JobObserver.jobs: {0}'.format(observer.jobs))
def not_support_plugin_test(self): """ specify plugin name that doesn't exists to module value in config file. """ cfg_lines = ('[global]', '', '[for_test]', 'module = NotExistsPlugin') ok_(ConfigReader(infile=cfg_lines))