def test_list_upd_pkg_mongo_file(self, mock_date): """Function: test_list_upd_pkg_mongo_file Description: Test writing to Mongo database and to a file. Arguments: """ mock_date.datetime.strftime.return_value = self.time_str package_admin.list_upd_pkg(self.args_array, self.yum, class_cfg=self.mongo_cfg) mongo = mongo_libs.crt_coll_inst(self.mongo_cfg, self.dbn, self.tbl) mongo.connect() if mongo.coll_find1()["Server"] == self.yum.hostname: status = filecmp.cmp(self.out_file, self.non_json_file) else: status = False mongo_libs.disconnect([mongo]) self.assertTrue(status)
def test_list_upd_pkg_mongo(self, mock_date): """Function: test_list_upd_pkg_mongo Description: Test writing to Mongo database. Arguments: """ mock_date.datetime.strftime.return_value = self.time_str package_admin.list_upd_pkg(self.args_array3, self.yum, class_cfg=self.mongo_cfg) mongo = mongo_libs.crt_coll_inst(self.mongo_cfg, self.dbn, self.tbl) mongo.connect() status = \ True if mongo.coll_find1()["Server"] == self.yum.hostname \ else False mongo_libs.disconnect([mongo]) self.assertTrue(status)
def test_list_upd_pkg_file(self, mock_date): """Function: test_list_upd_pkg_file Description: Test writing to file. Arguments: """ mock_date.datetime.strftime.return_value = self.time_str package_admin.list_upd_pkg(self.args_array2, self.yum, class_cfg=self.mongo_cfg) status = filecmp.cmp(self.out_file, self.non_json_file) self.assertTrue(status)
def test_mongo_failure(self, mock_yum): """Function: test_mongo_failure Description: Test with failed Mongo connection. Arguments: """ mock_yum.return_value = self.status2 self.assertEqual(package_admin.list_upd_pkg(self.args_array, self.yum), self.results)
def test_list_upd_pkg(self, mock_yum): """Function: test_list_upd_pkg Description: Test call to test_list_upd_pkg function. Arguments: """ mock_yum.return_value = self.status self.assertEqual(package_admin.list_upd_pkg(self.args_array, self.yum), self.status)
def test_mongo_successful(self, mock_yum): """Function: test_mongo_successful Description: Test with successful Mongo connection. Arguments: """ mock_yum.return_value = self.status self.assertEqual(package_admin.list_upd_pkg(self.args_array, self.yum), self.status)
def test_list_upd_pkg_out_std(self, mock_date): """Function: test_list_upd_pkg_out_std Description: Test writing to standard out. Arguments: """ mock_date.datetime.strftime.return_value = self.time_str self.assertEqual( package_admin.list_upd_pkg(self.args_array5, self.yum, class_cfg=self.mongo_cfg), (True, None))