mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
tests(storages): improve tests
add .cov config report ignores
This commit is contained in:
parent
071e006021
commit
25ecc6fafc
3 changed files with 19 additions and 1 deletions
|
|
@ -0,0 +1,5 @@
|
|||
[report]
|
||||
exclude_lines =
|
||||
pragma: no cover
|
||||
if TYPE_CHECKING:
|
||||
raise NotImplementedError
|
||||
|
|
@ -69,7 +69,7 @@ class TestCurrentUserContext:
|
|||
mocked.assert_awaited()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("getter_method", ("set_state", "set_data"))
|
||||
@pytest.mark.parametrize("getter_method", ("get_state", "get_data"))
|
||||
async def test_getters(self, storage, getter_method):
|
||||
chat_id, user_id = 1, 2
|
||||
ctx = CurrentUserContext(storage, chat_id, user_id)
|
||||
|
|
@ -78,6 +78,10 @@ class TestCurrentUserContext:
|
|||
await getattr(ctx, getter_method)()
|
||||
mocked.assert_awaited()
|
||||
|
||||
assert await getattr(ctx, getter_method)() == await getattr(storage, getter_method)(
|
||||
key=ctx.key
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("reseter_method", ("reset_data", "reset_state", "finish"))
|
||||
async def test_setters(self, storage, reseter_method):
|
||||
|
|
@ -116,3 +120,7 @@ class TestCurrentUserContext:
|
|||
new_data = LegitMapping()
|
||||
assert await ctx.update_data(data=new_data) is None
|
||||
assert await ctx.get_data() == new_data
|
||||
|
||||
await ctx.reset_data()
|
||||
assert await ctx.update_data(data=None) is None
|
||||
assert await ctx.get_data() == {}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ class TestDictStorage:
|
|||
assert await storage.reset_data(key=key) is None
|
||||
assert await storage.get_data(key=key) == {} # reset_data makes data empty dict
|
||||
|
||||
new_data = {"abc": "abc"}
|
||||
assert await storage.update_data(key=key, data=new_data) is None
|
||||
assert await storage.update_data(key=key, data=None) is None
|
||||
assert await storage.get_data(key=key) == new_data
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_finish(self):
|
||||
# finish turns data into initial one
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue