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


from tests import testlib
from splunklib.six.moves import range
    import unittest
    import unittest2 as unittest
import splunklib.client as client
        import unittest2 as unittest
        import unittest
        #self.service.namespace['owner'] = 'nobody'
        self.service.namespace['app'] = 'search'
        confs = self.service.kvstore
        if ('test' in confs):
            confs['test'].delete()
        confs.create('test')

        self.col = confs['test'].data

    def test_insert_find_update_data(self):
        data = [{'_key': str(x), 'data': '#' + str(x), 'num': x} for x in range(1000)]
        self.col.batch_save(*data)

        testData = self.col.query(sort='num')
        self.assertEqual(len(testData), 1000)

        for x in range(1000):
            self.assertEqual(testData[x]['_key'], str(x))
            self.assertEqual(testData[x]['data'], '#' + str(x))
            self.assertEqual(testData[x]['num'], x)

        data = [{'_key': str(x), 'data': '#' + str(x + 1), 'num': x + 1} for x in range(1000)]
        self.col.batch_save(*data)

        testData = self.col.query(sort='num')
        self.assertEqual(len(testData), 1000)

        for x in range(1000):
            self.assertEqual(testData[x]['_key'], str(x))
            self.assertEqual(testData[x]['data'], '#' + str(x + 1))

# 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_kvstore_batch.py
from tests import testlib
from splunklib.six.moves import range
    import unittest
    import unittest2 as unittest
import splunklib.client as client
        import unittest2 as unittest
        import unittest

        #self.service.namespace['owner'] = 'nobody'
        self.service.namespace['app'] = 'search'
        confs = self.service.kvstore
        if ('test' in confs):
            confs['test'].delete()
        confs.create('test')

        self.col = confs['test'].data

    def test_insert_find_update_data(self):
        data = [{'_key': str(x), 'data': '#' + str(x), 'num': x} for x in range(1000)]
        self.col.batch_save(*data)

        testData = self.col.query(sort='num')
        self.assertEqual(len(testData), 1000)

        for x in range(1000):
            self.assertEqual(testData[x]['_key'], str(x))
            self.assertEqual(testData[x]['data'], '#' + str(x))
            self.assertEqual(testData[x]['num'], x)

        data = [{'_key': str(x), 'data': '#' + str(x + 1), 'num': x + 1} for x in range(1000)]
        self.col.batch_save(*data)

        testData = self.col.query(sort='num')
        self.assertEqual(len(testData), 1000)

        for x in range(1000):
            self.assertEqual(testData[x]['_key'], str(x))
            self.assertEqual(testData[x]['data'], '#' + str(x + 1))

            self.assertEqual(testData[x]['num'], x + 1)