Skip to content

Commit e2a5712

Browse files
committed
test: fix make splunk home
1 parent 48eeb6e commit e2a5712

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

tests/integration/context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ def simple_requests(url, *args, **kwargs):
4343

4444
return simpleRequest(url, *args, **kwargs)
4545

46+
def make_splunkn_home(url, *args, **kwargs):
47+
from splunk.clilib.bundle_paths import make_splunkhome_path
48+
49+
return make_splunkhome_path(url, *args, **kwargs)
50+
4651
monkeypatch.setattr("solnlib.splunkenv.simpleRequest", simple_requests)
52+
monkeypatch.setattr("solnlib.splunkenv.msp", make_splunkn_home)

tests/integration/test_conf_manager.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ def test_get_log_level_incorrect_log_level_field(monkeypatch):
177177
assert expected_log_level == log_level
178178

179179

180-
def test_get_proxy_dict():
180+
def test_get_proxy_dict(monkeypatch):
181+
context.mock_splunk(monkeypatch)
182+
181183
session_key = context.get_session_key()
182184
expected_proxy_dict = VALID_PROXY_DICT
183185
proxy_dict = conf_manager.get_proxy_dict(
@@ -189,7 +191,9 @@ def test_get_proxy_dict():
189191
assert expected_proxy_dict == proxy_dict
190192

191193

192-
def test_invalid_proxy_port():
194+
def test_invalid_proxy_port(monkeypatch):
195+
context.mock_splunk(monkeypatch)
196+
193197
session_key = context.get_session_key()
194198

195199
with pytest.raises(soln_exceptions.InvalidPortError):
@@ -203,7 +207,9 @@ def test_invalid_proxy_port():
203207
)
204208

205209

206-
def test_invalid_proxy_host():
210+
def test_invalid_proxy_host(monkeypatch):
211+
context.mock_splunk(monkeypatch)
212+
207213
session_key = context.get_session_key()
208214

209215
with pytest.raises(soln_exceptions.InvalidHostnameError):
@@ -229,7 +235,9 @@ def test_conf_manager_exception():
229235
)
230236

231237

232-
def test_conf_stanza_not_exist_exception():
238+
def test_conf_stanza_not_exist_exception(monkeypatch):
239+
context.mock_splunk(monkeypatch)
240+
233241
session_key = context.get_session_key()
234242

235243
with pytest.raises(soln_exceptions.ConfStanzaNotExistException):

tests/integration/test_splunkenv.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
#
1616

17+
import context
1718
import os
1819
import os.path as op
1920
import sys
@@ -22,13 +23,17 @@
2223
sys.path.insert(0, op.dirname(op.dirname(op.abspath(__file__))))
2324

2425

25-
def test_splunkenv():
26+
def test_splunkenv(monkeypatch):
27+
context.mock_splunk(monkeypatch)
28+
2629
assert "SPLUNK_HOME" in os.environ
2730

31+
sk = context.get_session_key()
32+
2833
splunkhome_path = splunkenv.make_splunkhome_path(["etc", "apps"])
2934
assert splunkhome_path == op.join(os.environ["SPLUNK_HOME"], "etc", "apps")
3035

31-
server_name, host_name = splunkenv.get_splunk_host_info()
36+
server_name, host_name = splunkenv.get_splunk_host_info(sk)
3237
assert server_name
3338
assert host_name
3439

@@ -38,10 +43,10 @@ def test_splunkenv():
3843
op.join(os.environ["SPLUNK_HOME"], "bin", "splunk.exe"),
3944
]
4045

41-
scheme, host, port = splunkenv.get_splunkd_access_info()
46+
scheme, host, port = splunkenv.get_splunkd_access_info(sk)
4247
assert scheme
4348
assert host
4449
assert port
4550

46-
uri = splunkenv.get_splunkd_uri()
51+
uri = splunkenv.get_splunkd_uri(sk)
4752
assert uri == f"{scheme}://{host}:{port}"

0 commit comments

Comments
 (0)