def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.log = gen_class.LogFile() self.base_dir = "test/integration/check_log" self.test_path = os.path.join(os.getcwd(), self.base_dir, "testfiles") filename1 = "fetch_log_base_file.txt" filename2 = "fetch_log_base_file2.txt" self.logname1 = "fetch_log_file.txt" self.logname2 = "fetch_log_file2.txt" self.file_marker = os.path.join(self.test_path, "fetch_log_entry.txt") status, err_msg = gen_libs.cp_file(filename1, self.test_path, self.test_path, self.logname1) if not status: print("ERROR: Test environment setup failed. Message: %s" % (err_msg)) self.skipTest("Pre-conditions not met.") status, err_msg = gen_libs.cp_file(filename2, self.test_path, self.test_path, self.logname2) if not status: os.remove(os.path.join(self.test_path, self.logname1)) print("ERROR: Test environment setup failed. Message: %s" % (err_msg)) self.skipTest("Pre-conditions not met.") self.args_array = { "-f": [ os.path.join(self.test_path, self.logname2), os.path.join(self.test_path, self.logname1) ] } self.args_array2 = \ {"-f": [os.path.join(self.test_path, self.logname1)]} self.results = [ "This is the first line", "This is the second line", "This is the third line" ] self.results2 = [ "This is the first line", "This is the second line", "This is the third line", "This is the fourth line", "This is the fifth line", "This is the sixth line", "This is the seventh line" ] # Touch files to set correct time order, require sleep. gen_libs.touch(os.path.join(self.test_path, self.logname1)) time.sleep(1) gen_libs.touch(os.path.join(self.test_path, self.logname2))
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.log = gen_class.LogFile() self.args_array = {}
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.args_array = {} self.log = gen_class.LogFile() self.log.loglist = ["Testdata"] self.log_file = "/opt/local/check-log/logfile"
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.log = gen_class.LogFile() self.results0 = [""] self.results1 = ["Line one"] self.results2 = ["Line one", "Line two"]
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.line6 = "This is the sixth line" self.line7 = "This is the seventh line" data = ["This is the first line", "This is the second line", "This is the third line", "This is the fourth line", "This is the fifth line", self.line6, self.line7] self.log = gen_class.LogFile() self.log.loglist = data self.result = ["This is the fourth line", "This is the fifth line", self.line6, self.line7] self.result2 = [self.line7] self.result3 = data
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.log = gen_class.LogFile() self.file_0 = "test/unit/check_log/testfiles/fetch_log_file0.txt" self.file_1 = "test/unit/check_log/testfiles/fetch_log_file1.txt" self.file_2 = "test/unit/check_log/testfiles/fetch_log_file2.txt" self.file_3 = "test/unit/check_log/testfiles/fetch_log_file3.txt" self.args_array = {"-f": [self.file_1, self.file_2, self.file_3]} self.args_array2 = { "-f": [self.file_1, self.file_2, self.file_3], "-S": ["a"], "-k": "and" } self.args_array3 = { "-f": [self.file_1, self.file_2, self.file_3], "-S": ["a"], "-k": "or" } self.results0 = [] self.results1 = [ "This is line one of log", "This is line two of log", "This is line three of log" ] self.results2 = [ "This is line four of log", "This is line five of log", "This is line six of log", "This is line seven of log" ] self.results3 = [ "This is line one of log", "This is line two of log", "This is line three of log", "This is line four of log", "This is line five of log", "This is line six of log", "This is line seven of log" ]
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.log = gen_class.LogFile() self.log.loglist = ["first line of log", "second line of log"] self.base_dir = "test/integration/check_log" self.test_path = os.path.join(os.getcwd(), self.base_dir, "testfiles") self.file_name = os.path.join(self.test_path, "log_2_output_file.out") self.args_array = {} if os.access(self.file_name, os.W_OK): os.remove(self.file_name) elif os.path.isfile(self.file_name): print("ERROR: Test environment not clean - file: %s exists" % (self.file_name)) self.skipTest("Pre-conditions not met.")
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.line1 = "first line of log" self.line2 = "second line of log" self.outfile = "test/unit/check_log/testfiles/log_2_output_file.out" self.log = gen_class.LogFile() self.log.loglist = [self.line1, self.line2] self.args_array = {"-o": self.outfile, "-g": "w"} self.args_array2 = { "-o": self.outfile, "-z": True, "-w": True, "-g": "w" } self.args_array3 = {"-o": self.outfile, "-z": True, "-g": "a"} self.args_array4 = {"-o": self.outfile, "-z": True, "-g": "w"} self.msg = "Email Addresses"
def run_program(args_array, **kwargs): """Function: run_program Description: Controls the running of the program by fetching the log entries, updating the file marker, and sending the log entries to output. Arguments: (input) args_array -> Dictionary of command line options and values. """ args_array = dict(args_array) if "-c" in args_array and "-m" in args_array: gen_libs.clear_file(args_array["-m"]) else: log = gen_class.LogFile() load_attributes(log, args_array) if "-f" in args_array: fetch_log(log, args_array) elif not sys.stdin.isatty(): fetch_log_stdin(log) if log.loglist: if not full_chk(args_array): find_marker(log) log.filter_keyword() log.filter_ignore() log.filter_regex() log_2_output(log, args_array) update_marker(args_array, log.lastline)