# 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
import logging
import os
import time
import splunklib.client as client
    import unittest
    import unittest2 as unittest
import pytest
        import unittest2 as unittest
        import unittest
        event_count = int(self.index['totalEventCount'])
        self.assertEqual(self.index['sync'], '0')
        self.assertEqual(self.index['disabled'], '0')
        self.index.submit("Hello again!", sourcetype="Boris", host="meep")
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=50)

    def test_submit_namespaced(self):
        s = client.connect(**{
            "username": self.service.username,
            "password": self.service.password,
            "owner": "nobody",
            "app": "search"
        })
        i = s.indexes[self.index_name]

        event_count = int(i['totalEventCount'])
        self.assertEqual(i['sync'], '0')
        self.assertEqual(i['disabled'], '0')
        i.submit("Hello again namespaced!", sourcetype="Boris", host="meep")
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=50)

    def test_submit_via_attach(self):
        event_count = int(self.index['totalEventCount'])
        cn = self.index.attach()
        cn.send(b"Hello Boris!\r\n")
        cn.close()
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=60)

    def test_submit_via_attach_using_token_header(self):
        # Remove the prefix from the token

# 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_index.py
from tests import testlib
import logging
import os
import time
import splunklib.client as client
    import unittest
    import unittest2 as unittest
import pytest
        import unittest2 as unittest
        import unittest

        event_count = int(self.index['totalEventCount'])
        self.assertEqual(self.index['sync'], '0')
        self.assertEqual(self.index['disabled'], '0')
        self.index.submit("Hello again!", sourcetype="Boris", host="meep")
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=50)

    def test_submit_namespaced(self):
        s = client.connect(**{
            "username": self.service.username,
            "password": self.service.password,
            "owner": "nobody",
            "app": "search"
        })
        i = s.indexes[self.index_name]

        event_count = int(i['totalEventCount'])
        self.assertEqual(i['sync'], '0')
        self.assertEqual(i['disabled'], '0')
        i.submit("Hello again namespaced!", sourcetype="Boris", host="meep")
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=50)

    def test_submit_via_attach(self):
        event_count = int(self.index['totalEventCount'])
        cn = self.index.attach()
        cn.send(b"Hello Boris!\r\n")
        cn.close()
        self.assertEventuallyTrue(lambda: self.totalEventCount() == event_count+1, timeout=60)

    def test_submit_via_attach_using_token_header(self):
        # Remove the prefix from the token

        s = client.connect(**{'token': self.service.token.replace("Splunk ", "")})