Exemple #1
0
 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()
Exemple #2
0
 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()
Exemple #3
0
 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()
Exemple #4
0
 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."
Exemple #5
0
 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)
Exemple #6
0
 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()
Exemple #7
0
 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)