示例#1
0
    def test_execute_rules(self):

        rh = RDBSHub(self.data_source)

        ###
        #See RDBSHub.set_execute_rules for test descriptions
        ###

        #########
        #All tests should raise RDBSHubExecuteError
        #########

        # 1.) make sure we recognize all of the args, chicken being the exception here
        args = dict(chicken=1, proc='fake.proc', return_type='tuple')
        self.__try_it(rh, args)

        # 2.) proc or sql must be provided or we have nothing to execute
        args = dict(return_type='tuple', db=self.db)
        self.__try_it(rh, args)

        # 3.) placeholders and replace must be set to lists
        args = dict(placeholders=dict())
        self.__try_it(rh, args)
        args = dict(replace=dict())
        self.__try_it(rh, args)

        # 4.) key_column is required if the return type is dict, dict_json,
        # set, or set_json
        for key in rh.return_type_key_columns:
            args = dict(return_type=key, proc='fake.proc')
            self.__try_it(rh, args)

        # 5.) If a return type of callback is selected a callback key must be
        # provided wih a function reference
        args = dict(return_type='callback', proc='fake.proc')
        self.__try_it(rh, args)

        # 6.) chunk_size must be provided with a chunk_source
        args = dict(chunk_size=100, proc='fake.proc')
        self.__try_it(rh, args)
        args = dict(chunk_source='table.column', proc='fake.proc')
        self.__try_it(rh, args)