diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f3b0d1d470..1e7f64709f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,10 @@ in development Added ~~~~~ +* Enable setting ttl for MockDatastoreService. #5468 + + Contributed by @ytjohn + * Added st2 API and CLI command for actions clone operation. API endpoint ``/api/v1/actions/{ref_or_id}/clone`` takes ``ref_or_id`` of source action. diff --git a/st2tests/st2tests/mocks/datastore.py b/st2tests/st2tests/mocks/datastore.py index 0282a18ffd..e1adcde153 100644 --- a/st2tests/st2tests/mocks/datastore.py +++ b/st2tests/st2tests/mocks/datastore.py @@ -34,6 +34,7 @@ def __init__(self, logger, pack_name, class_name, api_username=None): self._pack_name = pack_name self._class_name = class_name self._username = api_username or "admin" + self._logger = logger # Holds mock KeyValuePair objects # Key is a KeyValuePair name and value is the KeyValuePair object @@ -96,10 +97,6 @@ def set_value( """ Store a value in a dictionary which is local to this class. """ - if ttl: - raise ValueError( - 'MockDatastoreService.set_value doesn\'t support "ttl" argument' - ) name = self._get_full_key_name(name=name, local=local) @@ -107,6 +104,11 @@ def set_value( instance.id = name instance.name = name instance.value = value + if ttl: + self._logger.warning( + "MockDatastoreService is not able to expire keys based on ttl." + ) + instance.ttl = ttl self._datastore_items[name] = instance return True