diff --git a/.gitignore b/.gitignore
index 05505fe74..5a7bf5b06 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,18 +11,14 @@ __stdout__
docs/_build
build/
proxypid
-proxy.log
MANIFEST
coverage_report
-test.log
-tests/searchcommands_data/log/
-tests/searchcommands_data/output/
Test Results*.html
-tests/searchcommands/data/app/app.log
+*.log
splunk_sdk.egg-info/
dist/
-tests/searchcommands/apps/app_with_logging_configuration/*.log
*.observed
venv/
+.venv/
.tox
test-reports/
diff --git a/docker-compose.yml b/docker-compose.yml
index 85250e232..b819386b0 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -20,10 +20,10 @@ services:
timeout: 5s
retries: 20
volumes:
- - "./tests/searchcommands/test_apps/eventing_app:/opt/splunk/etc/apps/eventing_app"
- - "./tests/searchcommands/test_apps/generating_app:/opt/splunk/etc/apps/generating_app"
- - "./tests/searchcommands/test_apps/reporting_app:/opt/splunk/etc/apps/reporting_app"
- - "./tests/searchcommands/test_apps/streaming_app:/opt/splunk/etc/apps/streaming_app"
+ - "./tests/system/test_apps/eventing_app:/opt/splunk/etc/apps/eventing_app"
+ - "./tests/system/test_apps/generating_app:/opt/splunk/etc/apps/generating_app"
+ - "./tests/system/test_apps/reporting_app:/opt/splunk/etc/apps/reporting_app"
+ - "./tests/system/test_apps/streaming_app:/opt/splunk/etc/apps/streaming_app"
- "./splunklib:/opt/splunk/etc/apps/eventing_app/lib/splunklib"
- "./splunklib:/opt/splunk/etc/apps/generating_app/lib/splunklib"
- "./splunklib:/opt/splunk/etc/apps/reporting_app/lib/splunklib"
diff --git a/tests/data/results.xml b/tests/integration/data/results.xml
similarity index 100%
rename from tests/data/results.xml
rename to tests/integration/data/results.xml
diff --git a/tests/data/streaming_results.xml b/tests/integration/data/streaming_results.xml
similarity index 100%
rename from tests/data/streaming_results.xml
rename to tests/integration/data/streaming_results.xml
diff --git a/tests/test_app.py b/tests/integration/test_app.py
similarity index 99%
rename from tests/test_app.py
rename to tests/integration/test_app.py
index a6194290a..52aceafe9 100755
--- a/tests/test_app.py
+++ b/tests/integration/test_app.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+
import logging
from tests import testlib
from splunklib import client
diff --git a/tests/test_binding.py b/tests/integration/test_binding.py
similarity index 100%
rename from tests/test_binding.py
rename to tests/integration/test_binding.py
diff --git a/tests/test_collection.py b/tests/integration/test_collection.py
similarity index 100%
rename from tests/test_collection.py
rename to tests/integration/test_collection.py
diff --git a/tests/test_conf.py b/tests/integration/test_conf.py
similarity index 100%
rename from tests/test_conf.py
rename to tests/integration/test_conf.py
diff --git a/tests/test_event_type.py b/tests/integration/test_event_type.py
similarity index 100%
rename from tests/test_event_type.py
rename to tests/integration/test_event_type.py
diff --git a/tests/test_fired_alert.py b/tests/integration/test_fired_alert.py
similarity index 100%
rename from tests/test_fired_alert.py
rename to tests/integration/test_fired_alert.py
diff --git a/tests/test_index.py b/tests/integration/test_index.py
similarity index 100%
rename from tests/test_index.py
rename to tests/integration/test_index.py
diff --git a/tests/test_input.py b/tests/integration/test_input.py
similarity index 100%
rename from tests/test_input.py
rename to tests/integration/test_input.py
diff --git a/tests/test_job.py b/tests/integration/test_job.py
similarity index 98%
rename from tests/test_job.py
rename to tests/integration/test_job.py
index c1c9ab004..7c781be3d 100755
--- a/tests/test_job.py
+++ b/tests/integration/test_job.py
@@ -15,6 +15,7 @@
# under the License.
from io import BytesIO
+from pathlib import Path
from time import sleep
import io
@@ -442,7 +443,9 @@ def test_results_reader(self):
# Run jobs.export("search index=_internal | stats count",
# earliest_time="rt", latest_time="rt") and you get a
# streaming sequence of XML fragments containing results.
- with io.open("data/results.xml", mode="br") as input:
+ test_dir = Path(__file__).parent
+ data_file = test_dir / "data" / "results.xml"
+ with io.open(str(data_file), mode="br") as input:
reader = results.ResultsReader(input)
self.assertFalse(reader.is_preview)
N_results = 0
@@ -464,7 +467,9 @@ def test_results_reader_with_streaming_results(self):
# Run jobs.export("search index=_internal | stats count",
# earliest_time="rt", latest_time="rt") and you get a
# streaming sequence of XML fragments containing results.
- with io.open("data/streaming_results.xml", "br") as input:
+ test_dir = Path(__file__).parent
+ data_file = test_dir / "data" / "streaming_results.xml"
+ with io.open(str(data_file), "br") as input:
reader = results.ResultsReader(input)
N_results = 0
N_messages = 0
diff --git a/tests/test_kvstore_batch.py b/tests/integration/test_kvstore_batch.py
similarity index 100%
rename from tests/test_kvstore_batch.py
rename to tests/integration/test_kvstore_batch.py
diff --git a/tests/test_kvstore_conf.py b/tests/integration/test_kvstore_conf.py
similarity index 100%
rename from tests/test_kvstore_conf.py
rename to tests/integration/test_kvstore_conf.py
diff --git a/tests/test_kvstore_data.py b/tests/integration/test_kvstore_data.py
similarity index 100%
rename from tests/test_kvstore_data.py
rename to tests/integration/test_kvstore_data.py
diff --git a/tests/test_logger.py b/tests/integration/test_logger.py
similarity index 98%
rename from tests/test_logger.py
rename to tests/integration/test_logger.py
index 0dca55171..f67d743a2 100755
--- a/tests/test_logger.py
+++ b/tests/integration/test_logger.py
@@ -16,7 +16,6 @@
from tests import testlib
-from splunklib import client
LEVELS = ["INFO", "WARN", "ERROR", "DEBUG", "CRIT"]
diff --git a/tests/test_macro.py b/tests/integration/test_macro.py
similarity index 100%
rename from tests/test_macro.py
rename to tests/integration/test_macro.py
diff --git a/tests/test_message.py b/tests/integration/test_message.py
similarity index 100%
rename from tests/test_message.py
rename to tests/integration/test_message.py
diff --git a/tests/test_modular_input.py b/tests/integration/test_modular_input.py
similarity index 100%
rename from tests/test_modular_input.py
rename to tests/integration/test_modular_input.py
diff --git a/tests/test_modular_input_kinds.py b/tests/integration/test_modular_input_kinds.py
similarity index 100%
rename from tests/test_modular_input_kinds.py
rename to tests/integration/test_modular_input_kinds.py
diff --git a/tests/test_results.py b/tests/integration/test_results.py
similarity index 100%
rename from tests/test_results.py
rename to tests/integration/test_results.py
diff --git a/tests/test_role.py b/tests/integration/test_role.py
similarity index 100%
rename from tests/test_role.py
rename to tests/integration/test_role.py
diff --git a/tests/test_saved_search.py b/tests/integration/test_saved_search.py
similarity index 100%
rename from tests/test_saved_search.py
rename to tests/integration/test_saved_search.py
diff --git a/tests/test_service.py b/tests/integration/test_service.py
similarity index 100%
rename from tests/test_service.py
rename to tests/integration/test_service.py
diff --git a/tests/test_storage_passwords.py b/tests/integration/test_storage_passwords.py
similarity index 99%
rename from tests/test_storage_passwords.py
rename to tests/integration/test_storage_passwords.py
index 972157835..c9fbd42c1 100644
--- a/tests/test_storage_passwords.py
+++ b/tests/integration/test_storage_passwords.py
@@ -21,6 +21,7 @@
class Tests(testlib.SDKTestCase):
def setUp(self):
+ # TODO: why not use super.setUp() ?
self.service = client.connect(**self.opts.kwargs)
self.storage_passwords = self.service.storage_passwords
diff --git a/tests/test_user.py b/tests/integration/test_user.py
similarity index 100%
rename from tests/test_user.py
rename to tests/integration/test_user.py
diff --git a/tests/searchcommands/test_apps/eventing_app/bin/eventingcsc.py b/tests/system/test_apps/eventing_app/bin/eventingcsc.py
similarity index 100%
rename from tests/searchcommands/test_apps/eventing_app/bin/eventingcsc.py
rename to tests/system/test_apps/eventing_app/bin/eventingcsc.py
diff --git a/tests/searchcommands/test_apps/eventing_app/default/app.conf b/tests/system/test_apps/eventing_app/default/app.conf
similarity index 100%
rename from tests/searchcommands/test_apps/eventing_app/default/app.conf
rename to tests/system/test_apps/eventing_app/default/app.conf
diff --git a/tests/searchcommands/test_apps/eventing_app/default/commands.conf b/tests/system/test_apps/eventing_app/default/commands.conf
similarity index 100%
rename from tests/searchcommands/test_apps/eventing_app/default/commands.conf
rename to tests/system/test_apps/eventing_app/default/commands.conf
diff --git a/tests/searchcommands/test_apps/eventing_app/metadata/default.meta b/tests/system/test_apps/eventing_app/metadata/default.meta
similarity index 100%
rename from tests/searchcommands/test_apps/eventing_app/metadata/default.meta
rename to tests/system/test_apps/eventing_app/metadata/default.meta
diff --git a/tests/searchcommands/test_apps/generating_app/bin/generatingcsc.py b/tests/system/test_apps/generating_app/bin/generatingcsc.py
similarity index 100%
rename from tests/searchcommands/test_apps/generating_app/bin/generatingcsc.py
rename to tests/system/test_apps/generating_app/bin/generatingcsc.py
diff --git a/tests/searchcommands/test_apps/generating_app/default/app.conf b/tests/system/test_apps/generating_app/default/app.conf
similarity index 100%
rename from tests/searchcommands/test_apps/generating_app/default/app.conf
rename to tests/system/test_apps/generating_app/default/app.conf
diff --git a/tests/searchcommands/test_apps/generating_app/default/commands.conf b/tests/system/test_apps/generating_app/default/commands.conf
similarity index 100%
rename from tests/searchcommands/test_apps/generating_app/default/commands.conf
rename to tests/system/test_apps/generating_app/default/commands.conf
diff --git a/tests/searchcommands/test_apps/generating_app/metadata/default.meta b/tests/system/test_apps/generating_app/metadata/default.meta
similarity index 100%
rename from tests/searchcommands/test_apps/generating_app/metadata/default.meta
rename to tests/system/test_apps/generating_app/metadata/default.meta
diff --git a/tests/searchcommands/test_apps/reporting_app/bin/reportingcsc.py b/tests/system/test_apps/reporting_app/bin/reportingcsc.py
similarity index 100%
rename from tests/searchcommands/test_apps/reporting_app/bin/reportingcsc.py
rename to tests/system/test_apps/reporting_app/bin/reportingcsc.py
diff --git a/tests/searchcommands/test_apps/reporting_app/default/app.conf b/tests/system/test_apps/reporting_app/default/app.conf
similarity index 100%
rename from tests/searchcommands/test_apps/reporting_app/default/app.conf
rename to tests/system/test_apps/reporting_app/default/app.conf
diff --git a/tests/searchcommands/test_apps/reporting_app/default/commands.conf b/tests/system/test_apps/reporting_app/default/commands.conf
similarity index 100%
rename from tests/searchcommands/test_apps/reporting_app/default/commands.conf
rename to tests/system/test_apps/reporting_app/default/commands.conf
diff --git a/tests/searchcommands/test_apps/reporting_app/metadata/default.meta b/tests/system/test_apps/reporting_app/metadata/default.meta
similarity index 100%
rename from tests/searchcommands/test_apps/reporting_app/metadata/default.meta
rename to tests/system/test_apps/reporting_app/metadata/default.meta
diff --git a/tests/searchcommands/test_apps/streaming_app/bin/streamingcsc.py b/tests/system/test_apps/streaming_app/bin/streamingcsc.py
similarity index 100%
rename from tests/searchcommands/test_apps/streaming_app/bin/streamingcsc.py
rename to tests/system/test_apps/streaming_app/bin/streamingcsc.py
diff --git a/tests/searchcommands/test_apps/streaming_app/default/app.conf b/tests/system/test_apps/streaming_app/default/app.conf
similarity index 100%
rename from tests/searchcommands/test_apps/streaming_app/default/app.conf
rename to tests/system/test_apps/streaming_app/default/app.conf
diff --git a/tests/searchcommands/test_apps/streaming_app/default/commands.conf b/tests/system/test_apps/streaming_app/default/commands.conf
similarity index 100%
rename from tests/searchcommands/test_apps/streaming_app/default/commands.conf
rename to tests/system/test_apps/streaming_app/default/commands.conf
diff --git a/tests/searchcommands/test_apps/streaming_app/metadata/default.meta b/tests/system/test_apps/streaming_app/metadata/default.meta
similarity index 100%
rename from tests/searchcommands/test_apps/streaming_app/metadata/default.meta
rename to tests/system/test_apps/streaming_app/metadata/default.meta
diff --git a/tests/searchcommands/test_csc_apps.py b/tests/system/test_csc_apps.py
similarity index 100%
rename from tests/searchcommands/test_csc_apps.py
rename to tests/system/test_csc_apps.py
diff --git a/tests/test_all.py b/tests/test_all.py
deleted file mode 100755
index 5c42e18eb..000000000
--- a/tests/test_all.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright © 2011-2023 Splunk, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"): you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-"""Runs all the Splunk SDK for Python unit tests."""
-
-import os
-import unittest
-
-os.chdir(os.path.dirname(os.path.abspath(__file__)))
-suite = unittest.defaultTestLoader.discover(".")
-
-if __name__ == "__main__":
- unittest.TextTestRunner().run(suite)
diff --git a/tests/data/custom_search/hashtags.baseline b/tests/unit/data/custom_search/hashtags.baseline
similarity index 100%
rename from tests/data/custom_search/hashtags.baseline
rename to tests/unit/data/custom_search/hashtags.baseline
diff --git a/tests/data/custom_search/hashtags.in b/tests/unit/data/custom_search/hashtags.in
similarity index 100%
rename from tests/data/custom_search/hashtags.in
rename to tests/unit/data/custom_search/hashtags.in
diff --git a/tests/data/custom_search/multibyte_input.gz b/tests/unit/data/custom_search/multibyte_input.gz
similarity index 100%
rename from tests/data/custom_search/multibyte_input.gz
rename to tests/unit/data/custom_search/multibyte_input.gz
diff --git a/tests/data/custom_search/tophashtags.baseline b/tests/unit/data/custom_search/tophashtags.baseline
similarity index 100%
rename from tests/data/custom_search/tophashtags.baseline
rename to tests/unit/data/custom_search/tophashtags.baseline
diff --git a/tests/data/custom_search/tophashtags.in b/tests/unit/data/custom_search/tophashtags.in
similarity index 100%
rename from tests/data/custom_search/tophashtags.in
rename to tests/unit/data/custom_search/tophashtags.in
diff --git a/tests/data/custom_search/usercount.baseline b/tests/unit/data/custom_search/usercount.baseline
similarity index 100%
rename from tests/data/custom_search/usercount.baseline
rename to tests/unit/data/custom_search/usercount.baseline
diff --git a/tests/data/custom_search/usercount.in b/tests/unit/data/custom_search/usercount.in
similarity index 100%
rename from tests/data/custom_search/usercount.in
rename to tests/unit/data/custom_search/usercount.in
diff --git a/tests/data/custom_search/v1_search_input.gz b/tests/unit/data/custom_search/v1_search_input.gz
similarity index 100%
rename from tests/data/custom_search/v1_search_input.gz
rename to tests/unit/data/custom_search/v1_search_input.gz
diff --git a/tests/data/services.server.info.xml b/tests/unit/data/services.server.info.xml
similarity index 100%
rename from tests/data/services.server.info.xml
rename to tests/unit/data/services.server.info.xml
diff --git a/tests/data/services.xml b/tests/unit/data/services.xml
similarity index 100%
rename from tests/data/services.xml
rename to tests/unit/data/services.xml
diff --git a/tests/modularinput/data/argument_with_defaults.xml b/tests/unit/modularinput/data/argument_with_defaults.xml
similarity index 100%
rename from tests/modularinput/data/argument_with_defaults.xml
rename to tests/unit/modularinput/data/argument_with_defaults.xml
diff --git a/tests/modularinput/data/argument_without_defaults.xml b/tests/unit/modularinput/data/argument_without_defaults.xml
similarity index 100%
rename from tests/modularinput/data/argument_without_defaults.xml
rename to tests/unit/modularinput/data/argument_without_defaults.xml
diff --git a/tests/modularinput/data/conf_with_0_inputs.xml b/tests/unit/modularinput/data/conf_with_0_inputs.xml
similarity index 100%
rename from tests/modularinput/data/conf_with_0_inputs.xml
rename to tests/unit/modularinput/data/conf_with_0_inputs.xml
diff --git a/tests/modularinput/data/conf_with_2_inputs.xml b/tests/unit/modularinput/data/conf_with_2_inputs.xml
similarity index 100%
rename from tests/modularinput/data/conf_with_2_inputs.xml
rename to tests/unit/modularinput/data/conf_with_2_inputs.xml
diff --git a/tests/modularinput/data/conf_with_invalid_inputs.xml b/tests/unit/modularinput/data/conf_with_invalid_inputs.xml
similarity index 100%
rename from tests/modularinput/data/conf_with_invalid_inputs.xml
rename to tests/unit/modularinput/data/conf_with_invalid_inputs.xml
diff --git a/tests/modularinput/data/event_maximal.xml b/tests/unit/modularinput/data/event_maximal.xml
similarity index 100%
rename from tests/modularinput/data/event_maximal.xml
rename to tests/unit/modularinput/data/event_maximal.xml
diff --git a/tests/modularinput/data/event_minimal.xml b/tests/unit/modularinput/data/event_minimal.xml
similarity index 100%
rename from tests/modularinput/data/event_minimal.xml
rename to tests/unit/modularinput/data/event_minimal.xml
diff --git a/tests/modularinput/data/scheme_with_defaults.xml b/tests/unit/modularinput/data/scheme_with_defaults.xml
similarity index 100%
rename from tests/modularinput/data/scheme_with_defaults.xml
rename to tests/unit/modularinput/data/scheme_with_defaults.xml
diff --git a/tests/modularinput/data/scheme_without_defaults.xml b/tests/unit/modularinput/data/scheme_without_defaults.xml
similarity index 100%
rename from tests/modularinput/data/scheme_without_defaults.xml
rename to tests/unit/modularinput/data/scheme_without_defaults.xml
diff --git a/tests/modularinput/data/scheme_without_defaults_and_argument_title.xml b/tests/unit/modularinput/data/scheme_without_defaults_and_argument_title.xml
similarity index 100%
rename from tests/modularinput/data/scheme_without_defaults_and_argument_title.xml
rename to tests/unit/modularinput/data/scheme_without_defaults_and_argument_title.xml
diff --git a/tests/modularinput/data/stream_with_one_event.xml b/tests/unit/modularinput/data/stream_with_one_event.xml
similarity index 100%
rename from tests/modularinput/data/stream_with_one_event.xml
rename to tests/unit/modularinput/data/stream_with_one_event.xml
diff --git a/tests/modularinput/data/stream_with_two_events.xml b/tests/unit/modularinput/data/stream_with_two_events.xml
similarity index 100%
rename from tests/modularinput/data/stream_with_two_events.xml
rename to tests/unit/modularinput/data/stream_with_two_events.xml
diff --git a/tests/modularinput/data/validation.xml b/tests/unit/modularinput/data/validation.xml
similarity index 100%
rename from tests/modularinput/data/validation.xml
rename to tests/unit/modularinput/data/validation.xml
diff --git a/tests/modularinput/data/validation_error.xml b/tests/unit/modularinput/data/validation_error.xml
similarity index 100%
rename from tests/modularinput/data/validation_error.xml
rename to tests/unit/modularinput/data/validation_error.xml
diff --git a/tests/modularinput/modularinput_testlib.py b/tests/unit/modularinput/modularinput_testlib.py
similarity index 100%
rename from tests/modularinput/modularinput_testlib.py
rename to tests/unit/modularinput/modularinput_testlib.py
diff --git a/tests/modularinput/test_event.py b/tests/unit/modularinput/test_event.py
similarity index 98%
rename from tests/modularinput/test_event.py
rename to tests/unit/modularinput/test_event.py
index ec98fa12c..4fd8e1771 100644
--- a/tests/modularinput/test_event.py
+++ b/tests/unit/modularinput/test_event.py
@@ -21,7 +21,7 @@
import pytest
-from tests.modularinput.modularinput_testlib import xml_compare, data_open
+from tests.unit.modularinput.modularinput_testlib import xml_compare, data_open
from splunklib.modularinput.event import Event, ET
from splunklib.modularinput.event_writer import EventWriter
diff --git a/tests/modularinput/test_input_definition.py b/tests/unit/modularinput/test_input_definition.py
similarity index 97%
rename from tests/modularinput/test_input_definition.py
rename to tests/unit/modularinput/test_input_definition.py
index a84cfa92a..7ac617e62 100644
--- a/tests/modularinput/test_input_definition.py
+++ b/tests/unit/modularinput/test_input_definition.py
@@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tests.modularinput.modularinput_testlib import unittest, data_open
+from tests.unit.modularinput.modularinput_testlib import unittest, data_open
from splunklib.modularinput.input_definition import InputDefinition
diff --git a/tests/modularinput/test_scheme.py b/tests/unit/modularinput/test_scheme.py
similarity index 97%
rename from tests/modularinput/test_scheme.py
rename to tests/unit/modularinput/test_scheme.py
index 51edb12bf..6fa3260ce 100644
--- a/tests/modularinput/test_scheme.py
+++ b/tests/unit/modularinput/test_scheme.py
@@ -14,7 +14,11 @@
# under the License.
import xml.etree.ElementTree as ET
-from tests.modularinput.modularinput_testlib import unittest, xml_compare, data_open
+from tests.unit.modularinput.modularinput_testlib import (
+ unittest,
+ xml_compare,
+ data_open,
+)
from splunklib.modularinput.scheme import Scheme
from splunklib.modularinput.argument import Argument
diff --git a/tests/modularinput/test_script.py b/tests/unit/modularinput/test_script.py
similarity index 99%
rename from tests/modularinput/test_script.py
rename to tests/unit/modularinput/test_script.py
index 1911caf21..9469048a8 100644
--- a/tests/modularinput/test_script.py
+++ b/tests/unit/modularinput/test_script.py
@@ -7,7 +7,7 @@
from splunklib.modularinput import Script, EventWriter, Scheme, Argument, Event
from splunklib.modularinput.utils import xml_compare
-from tests.modularinput.modularinput_testlib import data_open
+from tests.unit.modularinput.modularinput_testlib import data_open
TEST_SCRIPT_PATH = "__IGNORED_SCRIPT_PATH__"
diff --git a/tests/modularinput/test_validation_definition.py b/tests/unit/modularinput/test_validation_definition.py
similarity index 95%
rename from tests/modularinput/test_validation_definition.py
rename to tests/unit/modularinput/test_validation_definition.py
index a267902d8..53e8426b9 100644
--- a/tests/modularinput/test_validation_definition.py
+++ b/tests/unit/modularinput/test_validation_definition.py
@@ -15,7 +15,7 @@
# under the License.
-from tests.modularinput.modularinput_testlib import unittest, data_open
+from tests.unit.modularinput.modularinput_testlib import unittest, data_open
from splunklib.modularinput.validation_definition import ValidationDefinition
diff --git a/tests/searchcommands/__init__.py b/tests/unit/searchcommands/__init__.py
similarity index 100%
rename from tests/searchcommands/__init__.py
rename to tests/unit/searchcommands/__init__.py
diff --git a/tests/searchcommands/apps/app_with_logging_configuration/bin/empty-directory b/tests/unit/searchcommands/apps/app_with_logging_configuration/bin/empty-directory
similarity index 100%
rename from tests/searchcommands/apps/app_with_logging_configuration/bin/empty-directory
rename to tests/unit/searchcommands/apps/app_with_logging_configuration/bin/empty-directory
diff --git a/tests/searchcommands/apps/app_with_logging_configuration/default/alternative-logging.conf b/tests/unit/searchcommands/apps/app_with_logging_configuration/default/alternative-logging.conf
similarity index 100%
rename from tests/searchcommands/apps/app_with_logging_configuration/default/alternative-logging.conf
rename to tests/unit/searchcommands/apps/app_with_logging_configuration/default/alternative-logging.conf
diff --git a/tests/searchcommands/apps/app_with_logging_configuration/default/logging.conf b/tests/unit/searchcommands/apps/app_with_logging_configuration/default/logging.conf
similarity index 100%
rename from tests/searchcommands/apps/app_with_logging_configuration/default/logging.conf
rename to tests/unit/searchcommands/apps/app_with_logging_configuration/default/logging.conf
diff --git a/tests/searchcommands/apps/app_with_logging_configuration/logging.conf b/tests/unit/searchcommands/apps/app_with_logging_configuration/logging.conf
similarity index 100%
rename from tests/searchcommands/apps/app_with_logging_configuration/logging.conf
rename to tests/unit/searchcommands/apps/app_with_logging_configuration/logging.conf
diff --git a/tests/searchcommands/apps/app_without_logging_configuration/bin/empty-directory b/tests/unit/searchcommands/apps/app_without_logging_configuration/bin/empty-directory
similarity index 100%
rename from tests/searchcommands/apps/app_without_logging_configuration/bin/empty-directory
rename to tests/unit/searchcommands/apps/app_without_logging_configuration/bin/empty-directory
diff --git a/tests/searchcommands/apps/app_without_logging_configuration/default/empty-directory b/tests/unit/searchcommands/apps/app_without_logging_configuration/default/empty-directory
similarity index 100%
rename from tests/searchcommands/apps/app_without_logging_configuration/default/empty-directory
rename to tests/unit/searchcommands/apps/app_without_logging_configuration/default/empty-directory
diff --git a/tests/searchcommands/chunked_data_stream.py b/tests/unit/searchcommands/chunked_data_stream.py
similarity index 100%
rename from tests/searchcommands/chunked_data_stream.py
rename to tests/unit/searchcommands/chunked_data_stream.py
diff --git a/tests/searchcommands/test_builtin_options.py b/tests/unit/searchcommands/test_builtin_options.py
similarity index 99%
rename from tests/searchcommands/test_builtin_options.py
rename to tests/unit/searchcommands/test_builtin_options.py
index 849f4b79b..aa9648372 100644
--- a/tests/searchcommands/test_builtin_options.py
+++ b/tests/unit/searchcommands/test_builtin_options.py
@@ -29,7 +29,7 @@
from splunklib.searchcommands.decorators import Configuration
from splunklib.searchcommands.search_command import SearchCommand
-from tests.searchcommands import rebase_environment, package_directory
+from tests.unit.searchcommands import rebase_environment, package_directory
# portable log level names
diff --git a/tests/searchcommands/test_configuration_settings.py b/tests/unit/searchcommands/test_configuration_settings.py
similarity index 100%
rename from tests/searchcommands/test_configuration_settings.py
rename to tests/unit/searchcommands/test_configuration_settings.py
diff --git a/tests/searchcommands/test_decorators.py b/tests/unit/searchcommands/test_decorators.py
similarity index 99%
rename from tests/searchcommands/test_decorators.py
rename to tests/unit/searchcommands/test_decorators.py
index 533150ff5..a14c21959 100755
--- a/tests/searchcommands/test_decorators.py
+++ b/tests/unit/searchcommands/test_decorators.py
@@ -27,7 +27,7 @@
from splunklib.searchcommands.internals import json_encode_string
from splunklib.searchcommands.search_command import SearchCommand
-from tests.searchcommands import rebase_environment
+from tests.unit.searchcommands import rebase_environment
@Configuration()
diff --git a/tests/searchcommands/test_generator_command.py b/tests/unit/searchcommands/test_generator_command.py
similarity index 100%
rename from tests/searchcommands/test_generator_command.py
rename to tests/unit/searchcommands/test_generator_command.py
diff --git a/tests/searchcommands/test_internals_v1.py b/tests/unit/searchcommands/test_internals_v1.py
similarity index 100%
rename from tests/searchcommands/test_internals_v1.py
rename to tests/unit/searchcommands/test_internals_v1.py
diff --git a/tests/searchcommands/test_internals_v2.py b/tests/unit/searchcommands/test_internals_v2.py
similarity index 100%
rename from tests/searchcommands/test_internals_v2.py
rename to tests/unit/searchcommands/test_internals_v2.py
diff --git a/tests/searchcommands/test_multibyte_processing.py b/tests/unit/searchcommands/test_multibyte_processing.py
similarity index 100%
rename from tests/searchcommands/test_multibyte_processing.py
rename to tests/unit/searchcommands/test_multibyte_processing.py
diff --git a/tests/searchcommands/test_reporting_command.py b/tests/unit/searchcommands/test_reporting_command.py
similarity index 100%
rename from tests/searchcommands/test_reporting_command.py
rename to tests/unit/searchcommands/test_reporting_command.py
diff --git a/tests/searchcommands/test_search_command.py b/tests/unit/searchcommands/test_search_command.py
similarity index 99%
rename from tests/searchcommands/test_search_command.py
rename to tests/unit/searchcommands/test_search_command.py
index 7e1542107..9d5b4f494 100755
--- a/tests/searchcommands/test_search_command.py
+++ b/tests/unit/searchcommands/test_search_command.py
@@ -18,18 +18,13 @@
from json.encoder import encode_basestring as encode_string
from unittest import main, TestCase
-import csv
-import codecs
import os
-import re
import logging
from io import TextIOWrapper
-from unittest.mock import MagicMock, patch
import pytest
-import splunklib
from splunklib.searchcommands import Configuration, StreamingCommand
from splunklib.searchcommands.decorators import ConfigurationSetting, Option
from splunklib.searchcommands.internals import ObjectView
@@ -37,7 +32,7 @@
from splunklib.client import Service
from splunklib.utils import ensure_binary
-from io import StringIO, BytesIO
+from io import BytesIO
def build_command_input(getinfo_metadata, execute_metadata, execute_body):
diff --git a/tests/searchcommands/test_streaming_command.py b/tests/unit/searchcommands/test_streaming_command.py
similarity index 100%
rename from tests/searchcommands/test_streaming_command.py
rename to tests/unit/searchcommands/test_streaming_command.py
diff --git a/tests/searchcommands/test_validators.py b/tests/unit/searchcommands/test_validators.py
similarity index 100%
rename from tests/searchcommands/test_validators.py
rename to tests/unit/searchcommands/test_validators.py
diff --git a/tests/test_data.py b/tests/unit/test_data.py
similarity index 91%
rename from tests/test_data.py
rename to tests/unit/test_data.py
index 591f46b82..7fb24f967 100755
--- a/tests/test_data.py
+++ b/tests/unit/test_data.py
@@ -18,12 +18,12 @@
from os import path
import xml.etree.ElementTree as et
-from tests import testlib
+import unittest
from splunklib import data
-class DataTestCase(testlib.SDKTestCase):
+class DataTestCase(unittest.TestCase):
def test_elems(self):
result = data.load("")
self.assertTrue(result is None)
@@ -143,28 +143,35 @@ def test_invalid(self):
self.assertRaises(KeyError, data.load, "a")
def test_dict(self):
- result = data.load("""
+ result = data.load(
+ """
- """)
+ """
+ )
self.assertEqual(result, {})
- result = data.load("""
+ result = data.load(
+ """
v1
v2
- """)
+ """
+ )
self.assertEqual(result, {"n1": "v1", "n2": "v2"})
- result = data.load("""
+ result = data.load(
+ """
v1
v2
- """)
+ """
+ )
self.assertEqual(result, {"content": {"n1": "v1", "n2": "v2"}})
- result = data.load("""
+ result = data.load(
+ """
@@ -178,12 +185,14 @@ def test_dict(self):
- """)
+ """
+ )
self.assertEqual(
result, {"content": {"n1": {"n1n1": "n1v1"}, "n2": {"n2n1": "n2v1"}}}
)
- result = data.load("""
+ result = data.load(
+ """
@@ -192,28 +201,34 @@ def test_dict(self):
- """)
+ """
+ )
self.assertEqual(result, {"content": {"n1": ["1", "2", "3", "4"]}})
def test_list(self):
result = data.load("""
""")
self.assertEqual(result, [])
- result = data.load("""
+ result = data.load(
+ """
- 1
- 2
- 3
- 4
-
""")
+ """
+ )
self.assertEqual(result, ["1", "2", "3", "4"])
- result = data.load("""
+ result = data.load(
+ """
- 1
- 2
- 3
- 4
- """)
+ """
+ )
self.assertEqual(result, {"content": ["1", "2", "3", "4"]})
- result = data.load("""
+ result = data.load(
+ """
-
@@ -223,10 +238,12 @@ def test_list(self):
- 3
- 4
- """)
+ """
+ )
self.assertEqual(result, {"content": [["1", "2"], ["3", "4"]]})
- result = data.load("""
+ result = data.load(
+ """
- v1
@@ -234,19 +251,22 @@ def test_list(self):
- v3
- v4
- """)
+ """
+ )
self.assertEqual(
result,
{"content": [{"n1": "v1"}, {"n2": "v2"}, {"n3": "v3"}, {"n4": "v4"}]},
)
- result = data.load("""
+ result = data.load(
+ """
101089
i386
0
- """)
+ """
+ )
self.assertEqual(result, {"build": "101089", "cpu_arch": "i386", "isFree": "0"})
def test_record(self):
diff --git a/tests/test_utils.py b/tests/unit/test_utils.py
similarity index 71%
rename from tests/test_utils.py
rename to tests/unit/test_utils.py
index d8feafa5b..c6f826eda 100644
--- a/tests/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -1,6 +1,23 @@
-import unittest
+#!/usr/bin/env python
+#
+# Copyright © 2011-2025 Splunk, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"): you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
import os
-from tests import testlib
+from pathlib import Path
+import unittest
+
from utils import dslice
TEST_DICT = {
@@ -12,10 +29,7 @@
}
-class TestUtils(testlib.SDKTestCase):
- def setUp(self):
- super().setUp()
-
+class TestUtils(unittest.TestCase):
# Test dslice when a dict is passed to change key names
def test_dslice_dict_args(self):
args = {
@@ -77,8 +91,10 @@ def checkFilePermissions(dir_path):
else:
checkFilePermissions(path)
- dir_path = os.path.join("..", "splunklib")
- checkFilePermissions(dir_path)
+ test_file_path = Path(__file__)
+ # From tests/unit/test_file_permissions.py, go up 2 levels to project root, then to splunklib
+ splunklib_path = test_file_path.parent.parent.parent / "splunklib"
+ checkFilePermissions(str(splunklib_path))
if __name__ == "__main__":