Skip to content

Commit c14f4f3

Browse files
committed
Only check for is_preview in job result if ran on Splunk pre-v10
1 parent 27af6d8 commit c14f4f3

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish release
1+
name: Publish release to PyPI
22
on:
33
release:
44
types: [published]

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: Run test suite
1+
name: Python CI
22

33
on: [push, workflow_dispatch]
44

55
jobs:
66
test:
77
runs-on: ${{ matrix.os }}
88
strategy:
9+
fail-fast: false
910
matrix:
1011
os:
1112
- ubuntu-22.04
@@ -18,8 +19,6 @@ jobs:
1819
- "9.3"
1920
# - "9.4"
2021
# - "latest"
21-
22-
fail-fast: false
2322
steps:
2423
- name: Checkout repo
2524
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@ build-backend = "setuptools.build_meta"
4141
version = { attr = "splunklib.__version__" }
4242

4343
# https://docs.astral.sh/ruff/configuration/
44-
[tool.ruff]
45-
line-length = 120
46-
indent-width = 4
47-
48-
[tool.ruff.format]
49-
quote-style = "double"
50-
indent-style = "space"
51-
line-ending = "auto"
44+
# [tool.ruff]
5245

5346
[tool.ruff.lint]
5447
pydocstyle.convention = "google"

tests/searchcommands/test_csc_apps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
# under the License.
1616

1717
import unittest
18+
1819
import pytest
1920

20-
from tests import testlib
2121
from splunklib import results
22+
from tests import testlib
2223

2324

2425
@pytest.mark.smoke
@@ -71,7 +72,9 @@ def test_eventing_app(self):
7172
result = results.JSONResultsReader(stream)
7273
ds = list(result)
7374

74-
self.assertEqual(result.is_preview, False)
75+
if self.service.splunk_version < (10,):
76+
self.assertEqual(result.is_preview, False)
77+
7578
self.assertTrue(isinstance(ds[0], (dict, results.Message)))
7679
nonmessages = [d for d in ds if isinstance(d, dict)]
7780
self.assertTrue(len(nonmessages) <= 10)

tests/test_job.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ def test_oneshot(self):
5656
)
5757
result = results.JSONResultsReader(stream)
5858
ds = list(result)
59-
self.assertEqual(result.is_preview, False)
59+
60+
if self.service.splunk_version < (10,):
61+
self.assertEqual(result.is_preview, False)
62+
6063
self.assertTrue(isinstance(ds[0], dict) or isinstance(ds[0], results.Message))
6164
nonmessages = [d for d in ds if isinstance(d, dict)]
6265
self.assertTrue(len(nonmessages) <= 3)
@@ -72,7 +75,10 @@ def test_export(self):
7275
)
7376
result = results.JSONResultsReader(stream)
7477
ds = list(result)
75-
self.assertEqual(result.is_preview, False)
78+
79+
if self.service.splunk_version < (10,):
80+
self.assertEqual(result.is_preview, False)
81+
7682
self.assertTrue(isinstance(ds[0], dict) or isinstance(ds[0], results.Message))
7783
nonmessages = [d for d in ds if isinstance(d, dict)]
7884
self.assertTrue(len(nonmessages) <= 3)
@@ -92,7 +98,9 @@ def test_export_docstring_sample(self):
9298
elif isinstance(result, dict):
9399
# Normal events are returned as dicts
94100
pass # print(result)
95-
assert rr.is_preview == False
101+
102+
if self.service.splunk_version < (10,):
103+
self.assertFalse(rr.is_preview)
96104

97105
def test_results_docstring_sample(self):
98106
from splunklib import results
@@ -109,7 +117,9 @@ def test_results_docstring_sample(self):
109117
elif isinstance(result, dict):
110118
# Normal events are returned as dicts
111119
pass # print(result)
112-
assert rr.is_preview == False
120+
121+
if self.service.splunk_version < (10,):
122+
self.assertFalse(rr.is_preview)
113123

114124
def test_preview_docstring_sample(self):
115125
from splunklib import client
@@ -125,13 +135,14 @@ def test_preview_docstring_sample(self):
125135
elif isinstance(result, dict):
126136
# Normal events are returned as dicts
127137
pass # print(result)
128-
if rr.is_preview:
129-
pass # print("Preview of a running search job.")
130-
else:
131-
pass # print("Job is finished. Results are final.")
138+
139+
if self.service.splunk_version < (10,):
140+
if rr.is_preview:
141+
pass # print("Preview of a running search job.")
142+
else:
143+
pass # print("Job is finished. Results are final.")
132144

133145
def test_oneshot_docstring_sample(self):
134-
from splunklib import client
135146
from splunklib import results
136147

137148
service = self.service # cheat
@@ -145,7 +156,9 @@ def test_oneshot_docstring_sample(self):
145156
elif isinstance(result, dict):
146157
# Normal events are returned as dicts
147158
pass # print(result)
148-
assert rr.is_preview == False
159+
160+
if self.service.splunk_version < (10,):
161+
self.assertFalse(rr.is_preview)
149162

150163
def test_normal_job_with_garbage_fails(self):
151164
jobs = self.service.jobs

0 commit comments

Comments
 (0)