def test_create_repo(self): """Function: test_create_repo Description: Test create repo call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.append("-C") self.argv_list.append(self.repo_name) self.argv_list.append("-l") self.argv_list.append(self.repo_dir) cmdline.argv = self.argv_list elastic_db_repo.main() self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port, repo=self.repo_name) if self.repo_name in self.els.repo_dict: status = True else: status = False self.assertTrue(status)
def test_delete_dump(self): """Function: test_delete_dump Description: Test delete dump call. Arguments: """ global SKIP_PRINT global PRT_TEMPLATE global ERROR_PRINT cmdline = gen_libs.get_inst(sys) self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) status, msg = self.els.create_repo(self.repo_name, self.repo_dir) if status: print(ERROR_PRINT) print(PRT_TEMPLATE % (msg)) self.skipTest(SKIP_PRINT) els = elastic_class.ElasticSearchDump(self.cfg.host, repo=self.repo_name) els.dump_name = self.dump_name status, msg = els.dump_db() if status: print("Error detected for dump in repository: %s" % (self.repo_name)) print(PRT_TEMPLATE % (msg)) self.skipTest("Dump failed") self.argv_list.append("-S") self.argv_list.append(self.dump_name) self.argv_list.append("-r") self.argv_list.append(self.repo_name) cmdline.argv = self.argv_list elastic_db_repo.main() self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port, repo=self.repo_name) if self.dump_name not in elastic_class.get_dump_list( self.els.els, self.repo_name): status = True else: status = False self.assertTrue(status)
def test_list_dumps(self): """Function: test_list_dumps Description: Test list dumps call. Arguments: """ global SKIP_PRINT global PRT_TEMPLATE global ERROR_PRINT cmdline = gen_libs.get_inst(sys) self.argv_list.append("-L") self.argv_list.append(self.repo_name) cmdline.argv = self.argv_list self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) status, msg = self.els.create_repo(self.repo_name, self.repo_dir) if status: print(ERROR_PRINT) print(PRT_TEMPLATE % (msg)) self.skipTest(SKIP_PRINT) with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_disk_usage(self): """Function: test_disk_usage Description: Test disk usage call. Arguments: """ global SKIP_PRINT global PRT_TEMPLATE global ERROR_PRINT cmdline = gen_libs.get_inst(sys) self.argv_list.append("-U") cmdline.argv = self.argv_list self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) status, msg = self.els.create_repo(self.repo_name, self.repo_dir) if status: print(ERROR_PRINT) print(PRT_TEMPLATE % (msg)) self.skipTest(SKIP_PRINT) # Wait until the repo dir has been created. while True: if not os.path.isdir(self.phy_repo_dir): time.sleep(1) else: break with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_rename_repo(self): """Function: test_rename_repo Description: Test rename repo call. Arguments: """ global SKIP_PRINT global PRT_TEMPLATE global ERROR_PRINT cmdline = gen_libs.get_inst(sys) self.argv_list.append("-M") self.argv_list.append(self.repo_name2) self.argv_list.append(self.repo_name) cmdline.argv = self.argv_list self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) status, msg = self.els.create_repo(self.repo_name2, self.repo_dir) if status: print(ERROR_PRINT) print(PRT_TEMPLATE % (msg)) self.skipTest(SKIP_PRINT) elastic_db_repo.main() self.els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port, repo=self.repo_name) if self.repo_name in self.els.repo_dict: status = True else: status = False self.assertTrue(status)
def test_help_true(self, mock_arg, mock_help): """Function: test_help_true Description: Test with help_func returns True. Arguments: """ mock_arg.return_value = self.args mock_help.return_value = True self.assertFalse(elastic_db_repo.main())
def test_help_func(self): """Function: test_help_func Description: Test help call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.append("-v") cmdline.argv = self.argv_list with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_help_false(self, mock_arg, mock_help): """Function: test_help_false Description: Test with help_func returns False. Arguments: """ mock_arg.arg_parse2.return_value = self.args mock_help.return_value = False mock_arg.arg_require.return_value = True self.assertFalse(elastic_db_repo.main())
def test_arg_require(self): """Function: test_arg_require Description: Test arg require call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.remove("-c") self.argv_list.remove("elastic") cmdline.argv = self.argv_list with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_arg_cond_req_or(self): """Function: test_arg_cond_req_or Description: Test arg cond req or call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.append("-C") self.argv_list.append(self.repo_name) cmdline.argv = self.argv_list with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_arg_dir_chk_crt(self): """Function: test_arg_dir_chk_crt Description: Test arg dir chk crt call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.remove(self.config_path) self.argv_list.append("TEST_DIR") cmdline.argv = self.argv_list with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_arg_xor_dict(self): """Function: test_arg_xor_dict Description: Test arg xor dict call. Arguments: """ cmdline = gen_libs.get_inst(sys) self.argv_list.append("-U") self.argv_list.append("-D") self.argv_list.append(self.repo_name) cmdline.argv = self.argv_list with gen_libs.no_std_out(): self.assertFalse(elastic_db_repo.main())
def test_con_req_or_false(self, mock_arg, mock_help): """Function: test_con_req_or_false Description: Test with arg_cond_req_or returns False. Arguments: """ mock_arg.arg_parse2.return_value = self.args mock_help.return_value = False mock_arg.arg_require.return_value = False mock_arg.arg_xor_dict.return_value = True mock_arg.arg_cond_req_or.return_value = False self.assertFalse(elastic_db_repo.main())