Exemplo n.º 1
0
    def test_act__updates_state(self):
        expected = {'some': 'object'}
        target = Store(test_state)
        test_action = Action()
        test_action.act = Mock(return_value=expected)

        target.act(test_action)

        assert expected == target.state
Exemplo n.º 2
0
    def test_act__state_not_changed__subscriber_not_triggered(self):
        target = Store(test_state)
        subscriber = Mock()
        target.subscribe(subscriber)
        test_action = Action()
        test_action.act = lambda state: state

        target.act(test_action)

        subscriber.assert_not_called()
Exemplo n.º 3
0
    def test_act__state_changed__subscriber_triggered(self):
        expected = {'some': 'object'}
        target = Store(test_state)
        subscriber = Mock()
        target.subscribe(subscriber)
        test_action = Action()
        test_action.act = Mock(return_value=expected)

        target.act(test_action)

        subscriber.assert_called_once()
Exemplo n.º 4
0
    def test_act__action_gets_state(self):
        target = Store(test_state)

        test_action = Action()

        def assertion(state):
            assert test_state == state
            return state

        test_action.act = assertion

        target.act(test_action)
Exemplo n.º 5
0
    def test_act__returns_a_copy(self):
        target = Action()

        actual = target.act(test_state)

        assert test_state == actual
Exemplo n.º 6
0
    def test_act__returns_another_object(self):
        target = Action()

        actual = target.act(test_state)

        assert not test_state is actual