def test_component_on_destroyed(): component = Component(view=Mock(), presenter=Mock()) callback = Mock() component.on_destroyed.connect(callback) component.destroy() callback.assert_called_once_with(component)
def test_component_destroy_destroys_child_components(): component = Component(view=Mock(), presenter=Mock()) mock_cfactories = [MockComponentFactory() for _ in range(3)] mock_children = [tcast(Mock, component.new_component(mock_cfactory)) for mock_cfactory in mock_cfactories] component.destroy() for mock_child in mock_children: mock_child.destroy.assert_called_once_with()
def test_component_destroy(): mock_view = Mock() mock_presenter = Mock() component = Component(view=mock_view, presenter=mock_presenter) component.destroy() assert component.is_destroyed mock_view._destroy.assert_called_once_with() mock_presenter._destroy.assert_called_once_with()