# Path: tests/testlib.py
# class NoRestartRequiredError(Exception):
# class WaitTimedOutError(Exception):
# class SDKTestCase(unittest.TestCase):
# def to_bool(x):
# def tmpname():
# def wait(predicate, timeout=60, pause_time=0.5):
#     def assertEventuallyTrue(self, predicate, timeout=30, pause_time=0.5,
#                              timeout_message="Operation timed out."):
#     def check_content(self, entity, **kwargs):
#     def check_entity(self, entity):
#     def clear_restart_message(self):
#     def fake_splunk_version(self, version):
#     def install_app_from_collection(self, name):
#     def app_collection_installed(self):
#     def pathInApp(self, appName, pathComponents):
#     def uncheckedRestartSplunk(self, timeout=240):
#     def restartSplunk(self, timeout=240):
#     def setUpClass(cls):
#     def setUp(self):
#     def tearDown(self):
# 
# Path: splunklib/binding.py
# def _log_duration(f):
#     @wraps(f)
#     def new_f(*args, **kwargs):
#         start_time = datetime.now()
#         val = f(*args, **kwargs)
#         end_time = datetime.now()
#         logging.debug("Operation took %s", end_time-start_time)
#         return val
#     return new_f
# 
# class HTTPError(Exception):
#     """This exception is raised for HTTP responses that return an error."""
#     def __init__(self, response, _message=None):
#         status = response.status
#         reason = response.reason
#         body = response.body.read()
#         try:
#             detail = XML(body).findtext("./messages/msg")
#         except ParseError as err:
#             detail = body
#         message = "HTTP %d %s%s" % (
#             status, reason, "" if detail is None else " -- %s" % detail)
#         Exception.__init__(self, _message or message)
#         self.status = status
#         self.reason = reason
#         self.headers = response.headers
#         self.body = body
#         self._response = response


from io import BytesIO
from time import sleep
from tests import testlib
from splunklib.binding import _log_duration, HTTPError
        from datetime import datetime
                    from collections import OrderedDict
                    from splunklib.ordereddict import OrderedDict
                    from collections import OrderedDict
                    from splunklib.ordereddict import OrderedDict
import io
    import unittest2 as unittest
    import unittest
import splunklib.client as client
import splunklib.results as results
import pytest
        import splunklib.client as client
        import splunklib.results as results
        import splunklib.results as results
        import splunklib.client as client
        import splunklib.results as results
        import splunklib.client as client
        import splunklib.results as results
        rr = results.ResultsReader(job.preview())
        for result in rr:
            if isinstance(result, results.Message):
                # Diagnostic messages may be returned in the results
                pass #print '%s: %s' % (result.type, result.message)
            elif isinstance(result, dict):
                # Normal events are returned as dicts
                pass #print result
        if rr.is_preview:
            pass #print "Preview of a running search job."
        else:
            pass #print "Job is finished. Results are final."

    def test_oneshot_docstring_sample(self):
        service = self.service # cheat
        rr = results.ResultsReader(service.jobs.oneshot("search * | head 5"))
        for result in rr:
            if isinstance(result, results.Message):
                # Diagnostic messages may be returned in the results
                pass #print '%s: %s' % (result.type, result.message)
            elif isinstance(result, dict):
                # Normal events are returned as dicts
                pass #print result
        assert rr.is_preview == False

    def test_normal_job_with_garbage_fails(self):
        jobs = self.service.jobs
        try:
            bad_search = "abcd|asfwqqq"
            jobs.create(bad_search)

# Path: tests/testlib.py
# class NoRestartRequiredError(Exception):
# class WaitTimedOutError(Exception):
# class SDKTestCase(unittest.TestCase):
# def to_bool(x):
# def tmpname():
# def wait(predicate, timeout=60, pause_time=0.5):
#     def assertEventuallyTrue(self, predicate, timeout=30, pause_time=0.5,
#                              timeout_message="Operation timed out."):
#     def check_content(self, entity, **kwargs):
#     def check_entity(self, entity):
#     def clear_restart_message(self):
#     def fake_splunk_version(self, version):
#     def install_app_from_collection(self, name):
#     def app_collection_installed(self):
#     def pathInApp(self, appName, pathComponents):
#     def uncheckedRestartSplunk(self, timeout=240):
#     def restartSplunk(self, timeout=240):
#     def setUpClass(cls):
#     def setUp(self):
#     def tearDown(self):
# 
# Path: splunklib/binding.py
# def _log_duration(f):
#     @wraps(f)
#     def new_f(*args, **kwargs):
#         start_time = datetime.now()
#         val = f(*args, **kwargs)
#         end_time = datetime.now()
#         logging.debug("Operation took %s", end_time-start_time)
#         return val
#     return new_f
# 
# class HTTPError(Exception):
#     """This exception is raised for HTTP responses that return an error."""
#     def __init__(self, response, _message=None):
#         status = response.status
#         reason = response.reason
#         body = response.body.read()
#         try:
#             detail = XML(body).findtext("./messages/msg")
#         except ParseError as err:
#             detail = body
#         message = "HTTP %d %s%s" % (
#             status, reason, "" if detail is None else " -- %s" % detail)
#         Exception.__init__(self, _message or message)
#         self.status = status
#         self.reason = reason
#         self.headers = response.headers
#         self.body = body
#         self._response = response


# Path: tests/test_job.py
from io import BytesIO
from time import sleep
from tests import testlib
from splunklib.binding import _log_duration, HTTPError
        from datetime import datetime
                    from collections import OrderedDict
                    from splunklib.ordereddict import OrderedDict
                    from collections import OrderedDict
                    from splunklib.ordereddict import OrderedDict
import io
    import unittest2 as unittest
    import unittest
import splunklib.client as client
import splunklib.results as results
import pytest
        import splunklib.client as client
        import splunklib.results as results
        import splunklib.results as results
        import splunklib.client as client
        import splunklib.results as results
        import splunklib.client as client
        import splunklib.results as results

        rr = results.ResultsReader(job.preview())
        for result in rr:
            if isinstance(result, results.Message):
                # Diagnostic messages may be returned in the results
                pass #print '%s: %s' % (result.type, result.message)
            elif isinstance(result, dict):
                # Normal events are returned as dicts
                pass #print result
        if rr.is_preview:
            pass #print "Preview of a running search job."
        else:
            pass #print "Job is finished. Results are final."

    def test_oneshot_docstring_sample(self):
        service = self.service # cheat
        rr = results.ResultsReader(service.jobs.oneshot("search * | head 5"))
        for result in rr:
            if isinstance(result, results.Message):
                # Diagnostic messages may be returned in the results
                pass #print '%s: %s' % (result.type, result.message)
            elif isinstance(result, dict):
                # Normal events are returned as dicts
                pass #print result
        assert rr.is_preview == False

    def test_normal_job_with_garbage_fails(self):
        jobs = self.service.jobs
        try:
            bad_search = "abcd|asfwqqq"
            jobs.create(bad_search)

        except client.HTTPError as he: