Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions st2tests/st2tests/mocks/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,17 +97,18 @@ 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)

instance = KeyValuePair()
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
Expand Down