예제 #1
0
    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()
예제 #2
0
    def test_named_child_pop(self):
        """After pushing a child to a named stack, it can be popped back off."""
        child1 = BaseViewController()
        child2 = BaseViewController()

        child2.post_detach = MagicMock()
        child2.pre_detach = MagicMock()

        self.root.push_named_child('child-key', child1)
        self.root.push_named_child('child-key', child2)
        retrieved_child_2 = self.root.pop_named_child('child-key')
        self.assertEqual(child2, retrieved_child_2)
        child2.pre_detach.assert_called_with()
        child2.post_detach.assert_called_with()
        self.assertEqual(self.root.get_named_child('child-key'), child1)
예제 #3
0
    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()
예제 #4
0
    def test_named_child_pop(self):
        """After pushing a child to a named stack, it can be popped back off."""
        child1 = BaseViewController()
        child2 = BaseViewController()

        child2.post_detach = MagicMock()
        child2.pre_detach = MagicMock()

        self.root.push_named_child('child-key', child1)
        self.root.push_named_child('child-key', child2)
        retrieved_child_2 = self.root.pop_named_child('child-key')
        self.assertEqual(child2, retrieved_child_2)
        child2.pre_detach.assert_called_with()
        child2.post_detach.assert_called_with()
        self.assertEqual(self.root.get_named_child('child-key'), child1)
예제 #5
0
    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()
예제 #6
0
    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()