# 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):


import datetime
import logging
import splunklib.client as client
import pytest
        import unittest2 as unittest
        import unittest
from tests import testlib
from time import sleep
from splunklib.six.moves import zip
        query2 = '* earliest=-2m | head 2'
        namespace1 = client.namespace(app='search', sharing='app')
        namespace2 = client.namespace(owner='admin', app='search', sharing='user')
        saved_search2 = saved_searches.create(
            name, query2,
            namespace=namespace1)
        saved_search1 = saved_searches.create(
            name, query1,
            namespace=namespace2)

        self.assertRaises(client.AmbiguousReferenceException,
                          saved_searches.__getitem__, name)
        search1 = saved_searches[name, namespace1]
        self.check_saved_search(search1)
        search1.update(**{'action.email.from': 'nobody@nowhere.com'})
        search1.refresh()
        self.assertEqual(search1['action.email.from'], 'nobody@nowhere.com')
        search2 = saved_searches[name, namespace2]
        search2.update(**{'action.email.from': 'nemo@utopia.com'})
        search2.refresh()
        self.assertEqual(search2['action.email.from'], 'nemo@utopia.com')
        self.check_saved_search(search2)

    def test_dispatch(self):
        try:
            job = self.saved_search.dispatch()
            while not job.is_ready():
                sleep(0.1)
            self.assertTrue(job.sid in self.service.jobs)
        finally:

# 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: tests/test_saved_search.py
import datetime
import logging
import splunklib.client as client
import pytest
        import unittest2 as unittest
        import unittest
from tests import testlib
from time import sleep
from splunklib.six.moves import zip

        query2 = '* earliest=-2m | head 2'
        namespace1 = client.namespace(app='search', sharing='app')
        namespace2 = client.namespace(owner='admin', app='search', sharing='user')
        saved_search2 = saved_searches.create(
            name, query2,
            namespace=namespace1)
        saved_search1 = saved_searches.create(
            name, query1,
            namespace=namespace2)

        self.assertRaises(client.AmbiguousReferenceException,
                          saved_searches.__getitem__, name)
        search1 = saved_searches[name, namespace1]
        self.check_saved_search(search1)
        search1.update(**{'action.email.from': 'nobody@nowhere.com'})
        search1.refresh()
        self.assertEqual(search1['action.email.from'], 'nobody@nowhere.com')
        search2 = saved_searches[name, namespace2]
        search2.update(**{'action.email.from': 'nemo@utopia.com'})
        search2.refresh()
        self.assertEqual(search2['action.email.from'], 'nemo@utopia.com')
        self.check_saved_search(search2)

    def test_dispatch(self):
        try:
            job = self.saved_search.dispatch()
            while not job.is_ready():
                sleep(0.1)
            self.assertTrue(job.sid in self.service.jobs)
        finally:

            job.cancel()