예제 #1
0
    def test_process_yum_mongo_file(self, mock_date):

        """Function:  test_process_yum_mongo_file

        Description:  Test writing to Mongo database and to a file.

        Arguments:

        """

        mock_date.datetime.strftime.return_value = self.time_str

        package_admin.process_yum(self.args_array, self.yum, self.dict_key,
                                  self.func_name, 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)
예제 #2
0
    def test_process_yum_file_json(self, mock_date):

        """Function:  test_process_yum_file_json

        Description:  Test writing to file in JSON format.

        Arguments:

        """

        mock_date.datetime.strftime.return_value = self.time_str

        package_admin.process_yum(self.args_array6, self.yum, self.dict_key,
                                  self.func_name, class_cfg=self.mongo_cfg)

        status = filecmp.cmp(self.out_file, self.json_file)

        self.assertTrue(status)
예제 #3
0
    def test_suppression_false(self):
        """Function:  test_suppression_false

        Description:  Test with standard suppression set to false.

        Arguments:

        """

        self.assertEqual(
            package_admin.process_yum(self.args_array, self.yum, self.dict_key,
                                      self.func_name), self.status)
예제 #4
0
    def test_suppress_false_json(self):
        """Function:  test_suppress_false_json

        Description:  Test with standard suppression in JSON format.

        Arguments:

        """

        self.args_array["-f"] = True

        self.assertEqual(
            package_admin.process_yum(self.args_array, self.yum, self.dict_key,
                                      self.func_name), self.status)
예제 #5
0
    def test_process_yum_out_std(self, mock_date):

        """Function:  test_process_yum_out_std

        Description:  Test writing to standard out.

        Arguments:

        """

        mock_date.datetime.strftime.return_value = self.time_str

        self.assertEqual(
            package_admin.process_yum(
                self.args_array5, self.yum, self.dict_key, self.func_name,
                class_cfg=self.mongo_cfg), self.results)
예제 #6
0
    def test_write_file_true(self, mock_write):
        """Function:  test_write_file_true

        Description:  Test with write to file is set to True.

        Arguments:

        """

        mock_write.return_value = True

        self.args_array["-o"] = "File_Name"
        self.args_array["-z"] = True

        self.assertEqual(
            package_admin.process_yum(self.args_array, self.yum, self.dict_key,
                                      self.func_name), self.status)
예제 #7
0
    def test_email_std(self, mock_mail):
        """Function:  test_email_std

        Description:  Test with email in standard format.

        Arguments:

        """

        mock_mail.return_value = self.mail

        self.assertEqual(
            package_admin.process_yum(self.args_array2,
                                      self.yum,
                                      self.dict_key,
                                      self.func_name,
                                      class_cfg=self.class_cfg), self.status)
예제 #8
0
    def test_mailx_json(self, mock_mail):
        """Function:  test_mailx_json

        Description:  Test with mailx in json format.

        Arguments:

        """

        mock_mail.return_value = self.mail

        self.assertEqual(
            package_admin.process_yum(self.args_array3a,
                                      self.yum,
                                      self.dict_key,
                                      self.func_name,
                                      class_cfg=self.class_cfg), self.status)
예제 #9
0
    def test_mongo_insert(self, mock_insert):
        """Function:  test_mongo_insert

        Description:  Test with sending data to Mongo database.

        Arguments:

        """

        mock_insert.return_value = self.status

        self.args_array["-z"] = True

        self.assertEqual(
            package_admin.process_yum(self.args_array,
                                      self.yum,
                                      self.dict_key,
                                      self.func_name,
                                      class_cfg=self.class_cfg), self.status)
예제 #10
0
    def test_mongo_conn_success(self, mock_insert):
        """Function:  test_mongo_conn_success

        Description:  Test with successful Mongo connection.

        Arguments:

        """

        mock_insert.return_value = self.status

        self.args_array["-z"] = True

        self.assertEqual(
            package_admin.process_yum(self.args_array,
                                      self.yum,
                                      self.dict_key,
                                      self.func_name,
                                      class_cfg=self.class_cfg), self.status)
예제 #11
0
    def test_append_file_json(self, mock_write):
        """Function:  test_append_file_json

        Description:  Test with append to file as formatted JSON.

        Arguments:

        """

        mock_write.return_value = True

        self.args_array["-o"] = "File_Name"
        self.args_array["-z"] = True
        self.args_array["-f"] = True
        self.args_array["-a"] = True

        self.assertEqual(
            package_admin.process_yum(self.args_array, self.yum, self.dict_key,
                                      self.func_name), self.status)