Пример #1
0
    def test_runs_std_imported(self, parser_mock):
        """Ensure run_job is able to correctly run bundled python functions."""
        from furious.job_utils import function_path_to_reference

        function = function_path_to_reference("email.parser.Parser")

        self.assertIs(parser_mock, function)
Пример #2
0
    def test_runs_builtin(self, dir_mock):
        """Ensure builtins are able to be loaded and correctly run."""
        from furious.job_utils import function_path_to_reference

        function = function_path_to_reference("dir")

        self.assertIs(dir_mock, function)
Пример #3
0
    def test_runs_classmethod(self):
        """Ensure classmethods are able to be loaded and correctly run."""
        from furious.job_utils import function_path_to_reference

        ThrowAway.i_was_ran = False

        function = function_path_to_reference(
            'furious.tests.test_job_utils.'
            'ThrowAway.run_me')

        function()
        self.assertTrue(ThrowAway.i_was_ran)
Пример #4
0
def _decode_callbacks(encoded_callbacks):
    """Decode the callbacks to an executable form."""
    from furious.job_utils import function_path_to_reference

    callbacks = {}
    for event, callback in encoded_callbacks.iteritems():
        if isinstance(callback, dict):
            callback = Async.from_dict(callback)
        else:
            callback = function_path_to_reference(callback)

        callbacks[event] = callback

    return callbacks