def test_handle__normal_without_children(self):
        converge_gateway = MockConvergeGateway()
        process = MockPipelineProcess(children=[])

        hdl_result = handlers.converge_gateway_handler(process,
                                                       converge_gateway,
                                                       MockStatus())

        process.sync_with_children.assert_not_called()

        Status.objects.finish.assert_called_once_with(converge_gateway)

        self.assertEqual(hdl_result.next_node, converge_gateway.next())
        self.assertFalse(hdl_result.should_return)
        self.assertFalse(hdl_result.should_sleep)
    def test_handle__sync_raise_exception(self):
        converge_gateway = MockConvergeGateway()
        e = ChildDataSyncError()
        process = MockPipelineProcess(children=[1, 2, 3], sync_exception=e)

        hdl_result = handlers.converge_gateway_handler(process,
                                                       converge_gateway,
                                                       MockStatus())

        process.sync_with_children.assert_called_once()

        Status.objects.fail.assert_called_once_with(
            converge_gateway,
            ex_data=
            'Sync branch context error, check data backend status please.')

        Status.objects.finish.assert_not_called()

        self.assertIsNone(hdl_result.next_node)
        self.assertTrue(hdl_result.should_return)
        self.assertTrue(hdl_result.should_sleep)