예제 #1
0
    def test_entering_value(self):
        ii = IntegerAdjustInput(1, get_mock_input(), get_mock_output(), name=ii_name)
        ii.refresh = lambda *args, **kwargs: None

        plus = 5
        minus = 4
        expected = 2

        def scenario():
            for i in range(plus):
                execute_shorthand(ii, "u")
            for i in range(minus):
                execute_shorthand(ii, "d")
            execute_shorthand(ii, 'e')
            assert not ii.is_active

        with patch.object(ii, 'idle_loop', side_effect=scenario) as p:
            return_value = ii.activate()
        assert return_value == expected
예제 #2
0
    def test_left_returns_none(self):
        ii = IntegerAdjustInput(1, get_mock_input(), get_mock_output(), name=ii_name)
        ii.refresh = lambda *args, **kwargs: None #not needed

        # Checking without changing value
        def scenario():
            ii.keymap["KEY_LEFT"]()
            assert not ii.in_foreground

        with patch.object(ii, 'idle_loop', side_effect=scenario) as p:
            return_value = ii.activate()
        assert return_value is None

        # Checking after entering some keys
        test_keys = "u"*5
        def scenario():
            for key in test_keys:
                execute_shorthand(ii, key)
            execute_shorthand(ii, 'l')
            assert not ii.in_foreground

        with patch.object(ii, 'idle_loop', side_effect=scenario) as p:
            return_value = ii.activate()
        assert return_value is None