def test_index_file(self): self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) fp = tempfile.TemporaryDirectory() project = self.config['projects']['project_list'][0] file_list = radiam.get_list_of_files(fp.name, self.config[project]) self.assertIsNotNone(file_list) fp.cleanup()
def test_get_file_meta(self): fp = tempfile.TemporaryDirectory() self.arguments['--rootdir'] = fp.name self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) project_key = self.config['projects']['project_list'][0] temppath = os.path.join(fp.name, "radiamtemp.txt") with open(temppath, "w") as textfile: textfile.write("testing") file_meta = radiam.get_file_meta(temppath, self.config, project_key) self.assertIsNotNone(file_meta) fp.cleanup()
def test_file_excluded(self): fp = tempfile.TemporaryDirectory() self.arguments['--rootdir'] = fp.name self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) project_key = self.config['projects']['project_list'][0] temppath = os.path.join(fp.name, "radiamtemp.txt") with open(temppath, "w") as textfile: textfile.write("testing") is_file_excluded = radiam.file_excluded(temppath, self.config[project_key]) self.assertFalse(is_file_excluded) fp.cleanup()
def set_config(self, projectname, rootdir): self.tray_options.update({ "projectname": projectname, "rootdir": rootdir }) self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) with open(configjson, "w") as json_file: json.dump(self.config, json_file) self.agent_config = { "tokenfile": tokenfile, "baseurl": self.config['api']['host'], "logger": self.logger } self.API = RadiamAPI(**self.agent_config) return "Config set."
def __init__(self, logger, dirs, arguments, tokenfile, resumefile): self.logger = logger self.dirs = dirs self.arguments = arguments self.resumefile = resumefile self.tray_options = {} self.config, self.load_config_status = radiam.load_config( dirs.user_data_dir, arguments, logger, self.tray_options) with open(configjson, "w") as json_file: json.dump(self.config, json_file) if self.load_config_status: self.config['api']['host'] = self.config['api']['host'].strip('/') self.agent_config = { "tokenfile": tokenfile, "baseurl": self.config['api']['host'], "logger": logger } self.API = RadiamAPI(**self.agent_config)
def test_crawl(self): fp = tempfile.TemporaryDirectory() self.arguments['--rootdir'] = fp.name self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) agent_config = { "tokenfile": tokenfile, "baseurl": self.config['api']['host'], "logger": logger } API = RadiamAPI(**agent_config) temppath = os.path.join(fp.name, "radiamtemp.txt") with open(temppath, "w") as textfile: textfile.write("testing") crawler = radiam.crawl(self.dirs, self.arguments, self.logger, self.config, API, self.tray_options) self.assertIsNone(crawler) fp.cleanup()
def test_load_config(self): self.config, self.load_config_status = radiam.load_config( self.dirs.user_data_dir, self.arguments, self.logger, self.tray_options) self.assertIsNotNone(self.config)