def test_flatten_json(self, mock_cmds, mock_date): """Function: test_flatten_json Description: Test option to flatten JSON data structure. Arguments: """ mock_cmds.return_value = self.results mock_date.return_value = self.setdate mongo_perf.mongo_stat(self.server, self.args_array4, class_cfg=self.class_cfg, req_arg=self.req_arg, ofile=self.ofile) self.assertTrue(filecmp.cmp(self.outfile3, self.ofile))
def test_write_file(self, mock_cmds, mock_date): """Function: test_write_file Description: Test option to write to file. Arguments: """ mock_cmds.return_value = self.results mock_date.return_value = self.setdate mongo_perf.mongo_stat(self.server, self.args_array3, class_cfg=self.class_cfg, req_arg=self.req_arg, ofile=self.ofile) self.assertTrue(filecmp.cmp(self.outfile, self.ofile))
def test_default(self, mock_mongo, mock_popen): """Function: test_default Description: Test with default settings. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_popen.return_value = self.subproc self.assertFalse(mongo_perf.mongo_stat(self.server, {}))
def test_empty_args_array(self, mock_popen): """Function: test_empty_args_array Description: Test with empty args_array. Arguments: """ mock_popen.return_value = self.subproc self.assertFalse( mongo_perf.mongo_stat(self.server, {}, req_arg=self.req_arg))
def test_polling(self, mock_mongo, mock_popen): """Function: test_polling Description: Test with polling option. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_popen.return_value = self.subproc self.assertFalse(mongo_perf.mongo_stat(self.server, self.args_array))
def test_no_suppress(self, mock_mongo, mock_cmds, mock_libs): """Function: test_no_suppress Description: Test with no suppression. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_cmds.return_value = self.results mock_libs.print_data.return_value = True self.assertFalse(mongo_perf.mongo_stat(self.server, self.args_array6))
def test_polling(self, mock_popen): """Function: test_polling Description: Test with polling option. Arguments: """ mock_popen.return_value = self.subproc self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array5, req_arg=self.req_arg))
def test_dict_format(self, mock_cmds): """Function: test_dict_format Description: Test with converting output data to dictionary. Arguments: """ mock_cmds.return_value = self.results self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array2, req_arg=self.req_arg))
def test_email(self, mock_mongo, mock_cmds, mock_libs, mock_mail): """Function: test_email Description: Test with email option. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_cmds.return_value = self.results mock_libs.print_data.return_value = True mock_mail.return_value = self.mail self.assertFalse(mongo_perf.mongo_stat(self.server, self.args_array7))
def test_def_subj_mailx(self, mock_mongo, mock_cmds, mock_libs, mock_mail): """Function: test_def_subj_mailx Description: Test with email default subject line using mailx. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_cmds.return_value = self.results mock_libs.print_data.return_value = True mock_mail.return_value = self.mail self.assertFalse(mongo_perf.mongo_stat(self.server, self.args_array7a))
def test_default_args_array(self, mock_popen): """Function: test_default_args_array Description: Test with default options. Arguments: """ mock_popen.return_value = self.subproc self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array, req_arg=self.req_arg))
def test_dict_format(self, mock_mongo, mock_cmds, mock_libs): """Function: test_dict_format Description: Test with converting output data to dictionary. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_cmds.return_value = self.results mock_libs.print_data.return_value = True mock_libs.get_date.return_value = "2020-04-09" self.assertFalse(mongo_perf.mongo_stat(self.server, self.args_array2))
def test_std_out_file(self, mock_popen): """Function: test_std_out_file Description: Test with standard out to file. Arguments: """ mock_popen.return_value = self.subproc self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array, req_arg=self.req_arg, ofile=self.ofile))
def test_suppress(self, mock_cmds, mock_date): """Function: test_suppress Description: Test option to standard JSON data structure. Arguments: """ mock_cmds.return_value = self.results mock_date.return_value = self.setdate self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array2, req_arg=self.req_arg))
def test_std_out_file(self, mock_mongo, mock_popen): """Function: test_std_out_file Description: Test with standard out to file. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_popen.return_value = self.subproc self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array, ofile=self.fname))
def test_write_file(self, mock_mongo, mock_cmds, mock_libs): """Function: test_write_file Description: Test write to file. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_cmds.return_value = self.results mock_libs.write_file.return_value = True self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array5, ofile=self.ofile))
def test_flatten_json(self, mock_mongo, mock_cmds): """Function: test_flatten_json Description: Test option to flatten JSON data structure. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_mongo.ins_doc.return_value = True mock_cmds.return_value = self.results self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array4, db_tbl=self.db_tbl))
def test_mongo(self, mock_mongo, mock_cmds): """Function: test_mongo Description: Test with sending data to mongo. Arguments: """ mock_mongo.return_value = (True, None) mock_cmds.return_value = self.results self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array2, db_tbl=self.db_tbl, class_cfg=self.class_cfg, req_arg=self.req_arg))
def test_insert_success(self, mock_mongo, mock_cmds): """Function: test_insert_success Description: Test with successful insert into Mongo. Arguments: """ mock_mongo.create_cmd.return_value = ["command"] mock_mongo.ins_doc.return_value = (True, None) mock_cmds.return_value = self.results self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array2, db_tbl=self.db_tbl, class_cfg=self.class_cfg))
def test_insert_fail(self, mock_mongo, mock_cmds): """Function: test_insert_fail Description: Test with failed insert into Mongo. Arguments: """ mock_mongo.return_value = (False, "Insert Failed") mock_cmds.return_value = self.results with gen_libs.no_std_out(): self.assertFalse( mongo_perf.mongo_stat(self.server, self.args_array2, db_tbl=self.db_tbl, class_cfg=self.class_cfg, req_arg=self.req_arg))