def runTest(self):
     """ This function will update event trigger under test database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server,
         self.db_name,
         func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     trigger_response = event_trigger_utils.verify_event_trigger(
         self.server, self.db_name, self.trigger_name)
     if not trigger_response:
         raise Exception("Could not find event trigger.")
     data = {
         "comment": "This is event trigger update comment",
         "id": self.event_trigger_id
     }
     put_response = self.tester.put(
         self.url + str(utils.SERVER_GROUP) + '/' +
         str(self.server_id) + '/' + str(self.db_id) +
         '/' + str(self.event_trigger_id),
         data=json.dumps(data),
         follow_redirects=True)
     self.assertEquals(put_response.status_code, 200)
 def runTest(self):
     """ This function will add event trigger under test database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server, self.db_name, func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     data = {
         "enabled": "O",
         "eventfunname": "%s.%s" % (self.schema_name, self.func_name),
         "eventname": "DDL_COMMAND_END",
         "eventowner": self.db_user,
         "name": "event_trigger_add_%s" % (str(uuid.uuid4())[1:8]),
         "providers": []
     }
     response = self.tester.post(self.url + str(utils.SERVER_GROUP) + '/' +
                                 str(self.server_id) + '/' +
                                 str(self.db_id) + '/',
                                 data=json.dumps(data),
                                 content_type='html/json')
     self.assertAlmostEquals(response.status_code, 200)
Example #3
0
    def runTest(self):
        """ This function will delete event trigger under test database. """
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con['data']["connected"]:
            raise Exception("Could not connect to database.")
        schema_response = schema_utils.verify_schemas(self.server,
                                                      self.db_name,
                                                      self.schema_name)
        if not schema_response:
            raise Exception("Could not find the schema.")
        func_name = self.function_info[1]
        func_response = trigger_funcs_utils.verify_trigger_function(
            self.server, self.db_name, func_name)
        if not func_response:
            raise Exception("Could not find the trigger function.")
        trigger_response = event_trigger_utils.verify_event_trigger(
            self.server, self.db_name, self.trigger_names[0])
        if not trigger_response:
            raise Exception("Could not find event trigger.")
        trigger_response = event_trigger_utils.verify_event_trigger(
            self.server, self.db_name, self.trigger_names[1])
        if not trigger_response:
            raise Exception("Could not find event trigger.")
        data = {'ids': self.event_trigger_ids}

        actual_response_code = True
        expected_response_code = False

        if self.is_positive_test:
            response = self.delete_multiple(data)
            actual_response_code = response.status_code
            expected_response_code = self.expected_data['status_code']

        self.assertEqual(actual_response_code, expected_response_code)
 def runTest(self):
     """ This function will update event trigger under test database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server, self.db_name, func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     trigger_response = event_trigger_utils.verify_event_trigger(
         self.server, self.db_name, self.trigger_name)
     if not trigger_response:
         raise Exception("Could not find event trigger.")
     data = {
         "comment": "This is event trigger update comment",
         "id": self.event_trigger_id
     }
     put_response = self.tester.put(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.event_trigger_id),
         data=json.dumps(data),
         follow_redirects=True)
     self.assertEquals(put_response.status_code, 200)
Example #5
0
 def runTest(self):
     """ This function will delete event trigger under test database. """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server, self.db_name, func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     trigger_response = event_trigger_utils.verify_event_trigger(
         self.server, self.db_name, self.trigger_names[0])
     if not trigger_response:
         raise Exception("Could not find event trigger.")
     trigger_response = event_trigger_utils.verify_event_trigger(
         self.server, self.db_name, self.trigger_names[1])
     if not trigger_response:
         raise Exception("Could not find event trigger.")
     data = {'ids': self.event_trigger_ids}
     del_response = self.tester.delete(self.url + str(utils.SERVER_GROUP) +
                                       '/' + str(self.server_id) + '/' +
                                       str(self.db_id) + '/',
                                       follow_redirects=True,
                                       data=json.dumps(data),
                                       content_type='html/json')
     self.assertEquals(del_response.status_code, 200)
Example #6
0
    def runTest(self):
        """ This function will delete event trigger under test database. """
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con['data']["connected"]:
            raise Exception("Could not connect to database.")
        schema_response = schema_utils.verify_schemas(self.server,
                                                      self.db_name,
                                                      self.schema_name)
        if not schema_response:
            raise Exception("Could not find the schema.")
        func_name = self.function_info[1]
        func_response = trigger_funcs_utils.verify_trigger_function(
            self.server, self.db_name, func_name)
        if not func_response:
            raise Exception("Could not find the trigger function.")
        trigger_response = event_trigger_utils.verify_event_trigger(
            self.server, self.db_name, self.trigger_name)
        if not trigger_response:
            raise Exception("Could not find event trigger.")

        if self.is_positive_test:
            response = self.get_event_trigger_functions()
            actual_response_code = response.status_code
            expected_response_code = self.expected_data['status_code']
        else:
            with patch(self.mock_data["function_name"],
                       return_value=eval(self.mock_data["return_value"])):
                response = self.get_event_trigger_functions()
                actual_response_code = response.status_code
                expected_response_code = self.expected_data['status_code']

        self.assertEqual(actual_response_code, expected_response_code)
    def runTest(self):
        """ This function will add event trigger under test database. """
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con['data']["connected"]:
            raise Exception("Could not connect to database.")
        schema_response = schema_utils.verify_schemas(self.server,
                                                      self.db_name,
                                                      self.schema_name)
        if not schema_response:
            raise Exception("Could not find the schema.")
        func_name = self.function_info[1]
        func_response = trigger_funcs_utils.verify_trigger_function(
            self.server,
            self.db_name,
            func_name)
        if not func_response:
            raise Exception("Could not find the trigger function.")

        self.test_data['eventfunname'] = "%s.%s" % (
            self.schema_name, self.func_name)
        self.test_data['eventowner'] = self.db_user
        self.test_data['name'] = "event_trigger_add_%s" % (
            str(uuid.uuid4())[1:8])
        actual_response_code = True
        expected_response_code = False

        if self.is_positive_test:
            self.create_event_trigger()
            expected_output = event_trigger_utils.verify_event_trigger_node(
                self)
            del self.test_data['eventfunname']
            self.assertDictEqual(expected_output, self.test_data)
        else:
            if hasattr(self, "error_creating_event_trigger"):
                with patch(self.mock_data["function_name"],
                           return_value=eval(self.mock_data["return_value"])):
                    response = self.create_event_trigger()
                    actual_response_code = response.status_code
                    expected_response_code = self.expected_data['status_code']

            if hasattr(self, "error_getting_event_trigger_oid"):
                with patch(self.mock_data["function_name"],
                           side_effect=eval(self.mock_data["return_value"])):
                    response = self.create_event_trigger()
                    actual_response_code = response.status_code
                    expected_response_code = self.expected_data['status_code']
            if hasattr(self, "internal_server_error"):
                with patch(self.mock_data["function_name"],
                           side_effect=eval(self.mock_data["return_value"])):
                    response = self.create_event_trigger()
                    actual_response_code = response.status_code
                    expected_response_code = self.expected_data['status_code']
            if hasattr(self, "parameter_missing"):
                del self.test_data['eventfunname']
                response = self.create_event_trigger()
                actual_response_code = response.status_code
                expected_response_code = self.expected_data['status_code']

            self.assertEqual(actual_response_code, expected_response_code)
 def runTest(self):
     """ This function will fetch added event trigger under test database.
     """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server,
         self.db_name,
         func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     response = self.tester.get(
         self.url +
         str(utils.SERVER_GROUP) + '/' + str(self.server_id) + '/' +
         str(self.db_id) + '/' + str(self.event_trigger_id),
         content_type='html/json'
     )
     self.assertEquals(response.status_code, 200)
    def runTest(self):
        """ This function will fetch added event trigger under test database.
        """
        db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                                 self.server_id, self.db_id)
        if not db_con['data']["connected"]:
            raise Exception("Could not connect to database.")
        schema_response = schema_utils.verify_schemas(self.server,
                                                      self.db_name,
                                                      self.schema_name)
        if not schema_response:
            raise Exception("Could not find the schema.")
        func_name = self.function_info[1]
        func_response = trigger_funcs_utils.verify_trigger_function(
            self.server,
            self.db_name,
            func_name)
        if not func_response:
            raise Exception("Could not find the trigger function.")

        actual_response_code = True
        expected_response_code = False
        if self.is_positive_test:
            if hasattr(self, "event_trigger_list"):
                response = self.get_event_trigger_list()
            else:
                response = self.get_event_trigger()
            actual_response_code = response.status_code
            expected_response_code = self.expected_data['status_code']
        else:
            if hasattr(self, "error_fetching_event_trigger"):
                with patch(self.mock_data["function_name"],
                           return_value=eval(self.mock_data["return_value"])):
                    if hasattr(self, "event_trigger_list"):
                        response = self.get_event_trigger_list()
                    else:
                        response = self.get_event_trigger()
                    actual_response_code = response.status_code
                    expected_response_code = self.expected_data['status_code']
            if hasattr(self, "wrong_event_trigger_id"):
                self.event_trigger_id = 99999
                response = self.get_event_trigger()
                actual_response_code = response.status_code
                expected_response_code = self.expected_data['status_code']

        self.assertEquals(actual_response_code, expected_response_code)
 def runTest(self):
     """ This function will fetch added event trigger under test database.
     """
     db_con = database_utils.connect_database(self, utils.SERVER_GROUP,
                                              self.server_id, self.db_id)
     if not db_con['data']["connected"]:
         raise Exception("Could not connect to database.")
     schema_response = schema_utils.verify_schemas(self.server,
                                                   self.db_name,
                                                   self.schema_name)
     if not schema_response:
         raise Exception("Could not find the schema.")
     func_name = self.function_info[1]
     func_response = trigger_funcs_utils.verify_trigger_function(
         self.server, self.db_name, func_name)
     if not func_response:
         raise Exception("Could not find the trigger function.")
     response = self.tester.get(
         self.url + str(utils.SERVER_GROUP) + '/' + str(self.server_id) +
         '/' + str(self.db_id) + '/' + str(self.event_trigger_id),
         content_type='html/json')
     self.assertEquals(response.status_code, 200)