Add function get_value to BaseStorage (#1594)

* Add function `get_value` to all built-in storage implementations, `FSMContext` and `SceneWizard` (#1431)

* Fix type hints

* Split up return statements in `get_value` functions

* Implement `get_value` method in `BaseStorage` and remove redundant implementations
This commit is contained in:
Arthur Khachaturov 2024-11-02 17:48:01 +03:00 committed by GitHub
parent fd014d2026
commit 592267dd99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 120 additions and 4 deletions

View file

@ -1004,6 +1004,24 @@ class TestSceneWizard:
wizard.state.get_data.assert_called_once_with()
async def test_scene_wizard_get_value_with_default(self):
wizard = SceneWizard(
scene_config=AsyncMock(),
manager=AsyncMock(),
state=AsyncMock(),
update_type="message",
event=AsyncMock(),
data={},
)
args = ("test_key", "test_default")
value = "test_value"
wizard.state.get_value = AsyncMock(return_value=value)
result = await wizard.get_value(*args)
wizard.state.get_value.assert_called_once_with(*args)
assert result == value
async def test_scene_wizard_update_data_if_data(self):
wizard = SceneWizard(
scene_config=AsyncMock(),