-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
SUMMARY
When using MockDatastoreService.set_value() for unit testing (e.g. via BaseActionTestCase), a ValueError exception will be raised if ttl argument is specified.
STACKSTORM VERSION
st2 3.1.0, on Python 3.6.8
OS, environment, install method
Custom install, but not relevant to this case, see below.
Steps to reproduce the problem
See code for MockDatastoreService.set_value(). If ttl argument is specified, ValueError will explicitly be raised.
class MockDatastoreService(BaseDatastoreService):
# ...
def set_value(self, name, value, ttl=None, local=True, scope=SYSTEM_SCOPE, encrypt=False):
"""
Store a value in a dictionary which is local to this class.
"""
if ttl:
raise ValueError('MockDatastoreService.set_value doesn\'t support "ttl" argument')
# ...Expected Results
Both action_service.set_value() and sensor_service.set_value() support ttl argument. Although I understand that this argument cannot be honored in a mock situation, MockDatastoreService should be consistent with the behavior of the class it is mocking - perhaps fire a warning instead of an Exception?
Actual Results
An exception is returned while running tests:
ValueError: MockDatastoreService.set_value doesn't support "ttl" argumentIt is not possible to test actions or sensors that use xxx.set_value() with a ttl argument.