Ejemplo n.º 1
0
    def test_middleware__next_is_called(self):
        next = Mock()
        action = Action()
        middleware = restart_middleware_creator(None)

        middleware(next)(action)

        next.assert_called_once_with(action)
Ejemplo n.º 2
0
    def test_middleware__basic_action__returns_what_next_returns(self):
        expected = {'some': 'thing'}
        next = Mock(return_value=expected)
        action = Action()
        middleware = restart_middleware_creator(None)

        actual = middleware(next)(action)

        assert expected == actual
Ejemplo n.º 3
0
    def test_middleware__restart_action__restart_called(self):
        next = Mock()
        action = RestartAction(State())
        restart = Mock()
        middleware = restart_middleware_creator(restart)

        middleware(next)(action)

        restart.assert_called_once()
Ejemplo n.º 4
0
    def test_middleware__basic_action__restart_is_not_called(self):
        next = Mock()
        action = Action()
        restart = Mock()
        middleware = restart_middleware_creator(restart)

        middleware(next)(action)

        restart.assert_not_called()
Ejemplo n.º 5
0
    def test_middleware__restart_action__returns_what_next_returns(self):
        expected = {'some': 'thing'}
        next = Mock(return_value=expected)
        action = RestartAction(State())
        restart = Mock()
        middleware = restart_middleware_creator(restart)

        actual = middleware(next)(action)

        assert expected == actual
Ejemplo n.º 6
0
from src.relays.set_state import set_state
from src.relays.render import render_state
from src.game.store import Store, init_state

from src.game.middlewares import restart_middleware_creator
from src.relays.restart import restart_creator

restart = restart_creator(set_state)
restart_middleware = restart_middleware_creator(restart)


def create_store():
    store = Store(init_state, [restart_middleware])
    store.subscribe(render_state)
    return store