1515# under the License.
1616
1717"""Shared unit test utilities."""
18+ import contextlib
1819
1920import sys
2021# Run the test suite on the SDK without installing it.
@@ -125,7 +126,7 @@ def check_entity(self, entity):
125126 continue
126127 raise
127128
128- def clearRestartMessage (self ):
129+ def clear_restart_message (self ):
129130 """Tell Splunk to forget that it needs to be restarted.
130131
131132 This is used mostly in cases such as deleting a temporary application.
@@ -142,7 +143,17 @@ def clearRestartMessage(self):
142143 else :
143144 raise
144145
145- def installAppFromCollection (self , name ):
146+ @contextlib .contextmanager
147+ def fake_splunk_version (self , version ):
148+ original_version = self .service .splunk_version
149+ try :
150+ self .service ._splunk_version = version
151+ yield
152+ finally :
153+ self .service ._splunk_version = original_version
154+
155+
156+ def install_app_from_collection (self , name ):
146157 collectionName = 'sdk-app-collection'
147158 if collectionName not in self .service .apps :
148159 raise ValueError ("sdk-test-application not installed in splunkd" )
@@ -159,7 +170,7 @@ def pathInApp(self, appName, pathComponents):
159170 """Return a path to *pathComponents* in *appName*.
160171
161172 `pathInApp` is used to refer to files in applications installed with
162- `installAppFromCollection `. For example, the app `file_to_upload` in
173+ `install_app_from_collection `. For example, the app `file_to_upload` in
163174 the collection contains `log.txt`. To get the path to it, call::
164175
165176 pathInApp('file_to_upload', ['log.txt'])
@@ -228,4 +239,4 @@ def tearDown(self):
228239 self .service .apps .delete (appName )
229240 wait (lambda : appName not in self .service .apps )
230241 if self .service .restart_required :
231- self .clearRestartMessage ()
242+ self .clear_restart_message ()
0 commit comments