def runTest(self):
        """This function will deletes pgAgent job schedule"""
        if self.is_positive_test:
            if self.is_list:
                self.data['ids'] = [self.schedule_id, self.schedule_id_2]
                response = schedules_utils.api_delete(self, '')
            else:
                response = schedules_utils.api_delete(self)

            # Assert response
            utils.assert_status_code(self, response)

        is_present = pgagent_utils.verify_pgagent_schedule(self)
        self.assertFalse(is_present,
                         "pgAgent schedule was not deleted successfully")
Beispiel #2
0
    def runTest(self):
        # Check and Delete entry for pga_exception table for the above
        # date and time as no primary key is defined for pga_exception table
        # and there is a unique constraint for date and time. So when we run
        # the test cases multiple time then it will fail with unique
        # constraint error.
        if 'jscexceptions' in self.data:
            jexdate = self.data['jscexceptions'][0]["jexdate"]
            jextime = self.data['jscexceptions'][0]["jextime"]
            pgagent_utils.delete_pgagent_exception(self, jexdate, jextime)

        self.pgagent_schedule_name = "test_sch_add%s" % str(uuid.uuid4())[1:8]

        if "jscjobid" in self.data:
            self.data["jscjobid"] = self.job_id
            self.data["jscname"] = self.pgagent_schedule_name

        if self.is_positive_test:
            response = schedules_utils.api_create(self)

            # Assert response
            utils.assert_status_code(self, response)

            # Verify in backend
            response_data = json.loads(response.data)
            self.schedule_id = response_data['node']['_id']
            is_present = pgagent_utils.verify_pgagent_schedule(self)
            self.assertTrue(is_present,
                            "pgAgent schedule was not created successfully.")

        else:
            if self.mocking_required:
                with patch(self.mock_data["function_name"],
                           side_effect=eval(self.mock_data["return_value"])):
                    response = schedules_utils.api_create(self)

                    # Assert response
                    utils.assert_status_code(self, response)
                    utils.assert_error_message(self, response)