def test_named_child_post_attach_call(self): """Child's post_attach method is called after it is attached to a parent.""" root = BaseViewController() child = BaseViewController() child.post_attach = MagicMock() root.set_named_child('child-key', child) child.post_attach.assert_called_with()
def test_named_child_post_attach_call(self): """Child's post_attach method is called after it is attached to a parent.""" root = BaseViewController() child = BaseViewController() child.post_attach = MagicMock() root.set_named_child('child-key', child) child.post_attach.assert_called_with()
def test_named_child_replacement_event_calls(self): """Replacing a named child calls the pre_detach and post_detach methods on the final controller in the stack that is being replaced.""" child1 = BaseViewController() child1.post_attach = MagicMock() child1.pre_detach = MagicMock() child1.post_detach = MagicMock() child2 = BaseViewController() self.root.set_named_child('child-key', child1) child1.post_attach.assert_called_with() self.root.set_named_child('child-key', child2) child1.pre_detach.assert_called_with() child1.post_detach.assert_called_with()
def test_named_child_replacement_event_calls(self): """Replacing a named child calls the pre_detach and post_detach methods on the final controller in the stack that is being replaced.""" child1 = BaseViewController() child1.post_attach = MagicMock() child1.pre_detach = MagicMock() child1.post_detach = MagicMock() child2 = BaseViewController() self.root.set_named_child('child-key', child1) child1.post_attach.assert_called_with() self.root.set_named_child('child-key', child2) child1.pre_detach.assert_called_with() child1.post_detach.assert_called_with()
def test_named_child_push(self): """After pushing a child to a named stack, it is then retrievable via child. The previous final controller on the stack should have its pre_detach and post_detach methods called.""" child1 = BaseViewController() child1.pre_detach = MagicMock() child1.post_detach = MagicMock() child2 = BaseViewController() child2.post_attach = MagicMock() self.root.push_named_child('child-key', child1) self.root.push_named_child('child-key', child2) self.assertEqual(self.root.get_named_child('child-key'), child2) child1.pre_detach.assert_called_with() child1.post_detach.assert_called_with() child2.post_attach.assert_called_with()
def test_named_child_push(self): """After pushing a child to a named stack, it is then retrievable via child. The previous final controller on the stack should have its pre_detach and post_detach methods called.""" child1 = BaseViewController() child1.pre_detach = MagicMock() child1.post_detach = MagicMock() child2 = BaseViewController() child2.post_attach = MagicMock() self.root.push_named_child('child-key', child1) self.root.push_named_child('child-key', child2) self.assertEqual(self.root.get_named_child('child-key'), child2) child1.pre_detach.assert_called_with() child1.post_detach.assert_called_with() child2.post_attach.assert_called_with()