From cabb10bc06d045f89adc9111ccc60c30fa7643d1 Mon Sep 17 00:00:00 2001 From: Suren Khorenyan Date: Sun, 21 Jul 2019 23:45:25 +0300 Subject: [PATCH] Create some tests --- .../test_filters/test_builtin.py | 18 ++++++++++++++++++ .../test_dispatcher/test_filters/test_state.py | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/test_dispatcher/test_filters/test_builtin.py create mode 100644 tests/test_dispatcher/test_filters/test_state.py diff --git a/tests/test_dispatcher/test_filters/test_builtin.py b/tests/test_dispatcher/test_filters/test_builtin.py new file mode 100644 index 00000000..86344cec --- /dev/null +++ b/tests/test_dispatcher/test_filters/test_builtin.py @@ -0,0 +1,18 @@ +import pytest + +from aiogram.dispatcher.filters.builtin import Text + + +class TestText: + + @pytest.mark.parametrize('param, key', [ + ('text', 'equals'), + ('text_contains', 'contains'), + ('text_startswith', 'startswith'), + ('text_endswith', 'endswith'), + ]) + def test_validate(self, param, key): + value = 'spam and eggs' + config = {param: value} + res = Text.validate(config) + assert res == {key: value} diff --git a/tests/test_dispatcher/test_filters/test_state.py b/tests/test_dispatcher/test_filters/test_state.py new file mode 100644 index 00000000..b7f5a5fd --- /dev/null +++ b/tests/test_dispatcher/test_filters/test_state.py @@ -0,0 +1,18 @@ +from aiogram.dispatcher.filters.state import StatesGroup + +class TestStatesGroup: + + def test_all_childs(self): + + class InnerState1(StatesGroup): + pass + + class InnerState2(InnerState1): + pass + + class Form(StatesGroup): + inner1 = InnerState1 + inner2 = InnerState2 + + form_childs = Form.all_childs + assert form_childs == (InnerState1, InnerState2)