Exemplo n.º 1
0
class TestFault(unittest.TestCase):
    """Tests for the Fault activity."""
    def setUp(self):
        """Set up test case."""

        xmlelement = ET.fromstring(procdsc)
        self.root = Process('', xmlelement, 'fake-id', Context())
        self.root.state = 'active'
        self.root.children[0].state = 'active'
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test handling message 'start'."""
        msg = Message(name='start', target='fake-id_1', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMsg:
            newmsg = Message(name='fault',
                             target='fake-id',
                             origin='fake-id_1',
                             payload={
                                 "code": "terminate",
                                 "message": ""
                             })
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            MockMsg.assert_called_once_with(name='fault',
                                            target='fake-id',
                                            origin='fake-id_1',
                                            payload={
                                                "code": "terminate",
                                                "message": ""
                                            })
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[1].state, "completed")

    def test_handle_message_start_return_code(self):
        """Test handling message 'start'. Expect custom error code."""
        msg = Message(name='start', target='fake-id_3', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMsg:
            newmsg = Message(name='fault',
                             target='fake-id',
                             origin='fake-id_3',
                             payload={
                                 "code": "SomeError",
                                 "message": "Some text"
                             })
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            MockMsg.assert_called_once_with(name='fault',
                                            target='fake-id',
                                            origin='fake-id_3',
                                            payload={
                                                "code": "SomeError",
                                                "message": "Some text"
                                            })
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[3].state, "completed")
Exemplo n.º 2
0
class TestFault(unittest.TestCase):
    """Tests for the Fault activity."""

    def setUp(self):
        """Set up test case."""

        xmlelement = ET.fromstring(procdsc)
        self.root = Process("", xmlelement, "fake-id", Context())
        self.root.state = "active"
        self.root.children[0].state = "active"
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test handling message 'start'."""
        msg = Message(name="start", target="fake-id_1", origin="fake-id")
        with patch("bureaucrat.flowexpression.Message") as MockMsg:
            newmsg = Message(
                name="fault", target="fake-id", origin="fake-id_1", payload={"code": "terminate", "message": ""}
            )
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, "consumed")
            MockMsg.assert_called_once_with(
                name="fault", target="fake-id", origin="fake-id_1", payload={"code": "terminate", "message": ""}
            )
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[1].state, "completed")

    def test_handle_message_start_return_code(self):
        """Test handling message 'start'. Expect custom error code."""
        msg = Message(name="start", target="fake-id_3", origin="fake-id")
        with patch("bureaucrat.flowexpression.Message") as MockMsg:
            newmsg = Message(
                name="fault",
                target="fake-id",
                origin="fake-id_3",
                payload={"code": "SomeError", "message": "Some text"},
            )
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, "consumed")
            MockMsg.assert_called_once_with(
                name="fault",
                target="fake-id",
                origin="fake-id_3",
                payload={"code": "SomeError", "message": "Some text"},
            )
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[3].state, "completed")
Exemplo n.º 3
0
class TestAssign(unittest.TestCase):
    """Tests for Assign activity."""

    def setUp(self):
        """Set up test case."""

        xmlelement = ET.fromstring(procdsc)
        self.root = Process('', xmlelement, 'fake-id', Context())
        self.root.state = 'active'
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test handling message 'start'."""
        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMsg:
            newmsg = Message(name='completed', target='fake-id',
                             origin='fake-id_0')
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            MockMsg.assert_called_once_with(name='completed', target='fake-id',
                                            origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[0].state, "completed")
            self.assertEqual(self.root.context.get("prop1"), 7)
Exemplo n.º 4
0
class TestAssign(unittest.TestCase):
    """Tests for Assign activity."""
    def setUp(self):
        """Set up test case."""

        xmlelement = ET.fromstring(procdsc)
        self.root = Process('', xmlelement, 'fake-id', Context())
        self.root.state = 'active'
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test handling message 'start'."""
        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMsg:
            newmsg = Message(name='completed',
                             target='fake-id',
                             origin='fake-id_0')
            MockMsg.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            MockMsg.assert_called_once_with(name='completed',
                                            target='fake-id',
                                            origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.children[0].state, "completed")
            self.assertEqual(self.root.context.get("prop1"), 7)
Exemplo n.º 5
0
class TestProcess(unittest.TestCase):
    """Tests for Process."""
    def setUp(self):
        xml_element = ET.fromstring(processdsc)
        self.fexpr = Process('', xml_element, 'fake-id', Context())
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test Process.handle_message() with start message."""

        msg = Message(name='start', target='fake-id', origin='')
        newmsg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.fexpr.state = 'ready'
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_completed1(self):
        """Test Process.handle_message() with completed msg from first child."""

        msg = Message(name='completed', target='fake-id', origin='fake-id_0')
        self.fexpr.state = 'active'
        newmsg = Message(name='start', target='fake-id_1', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_1',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_completed2(self):
        """Test Process.handle_message() with completed msg from last child."""

        msg = Message(name='completed', target='fake-id', origin='fake-id_1')
        self.fexpr.state = 'active'
        newmsg = Message(name='completed', target='', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'completed')
            MockMessage.assert_called_once_with(name='completed',
                                                target='',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_response(self):
        """Test Process.handle_message() with response msg for child."""

        msg = Message(name='response',
                      target='fake-id_0',
                      origin='fake-id_0',
                      payload={"status": "done"})
        self.fexpr.state = 'active'
        self.fexpr.children[0].state = 'active'
        newmsg = Message(name='completed',
                         target='fake-id',
                         origin='fake-id_0')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
Exemplo n.º 6
0
class TestForeach(unittest.TestCase):
    """Tests for Foreach activity."""

    def setUp(self):
        """Set up test case."""
        xml_element = ET.fromstring(procdsc)
        self.root = Process('', xml_element, 'fake-id', Context())
        self.foreach = self.root.children[0]
        self.ch = Mock()

    def test_handle_message_completed_state(self):
        """Test Foreach.handle_message() when Foreach is completed."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        self.foreach.state = 'completed'
        result = self.root.handle_message(self.ch, msg)
        self.assertEqual(result, 'ignored')

    def test_handle_message_wrong_target(self):
        """Test Foreach.handle_message() when message targeted not to it."""

        msg = Message(name='start', target='fake-id_10', origin='fake-id')
        self.root.state = 'active'
        self.foreach.state = 'active'
        result = self.root.handle_message(self.ch, msg)
        self.assertEqual(result, 'ignored')

    def test_handle_message_start_with_empty_select(self):
        """Test Foreach.handle_message() with start msg and empty select."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        self.root.context.set('prop2', {"subkey": []})
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='completed', target='fake-id',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'completed')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_start(self):
        """Test Foreach.handle_message() with start msg."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start', target='fake-id_0_0',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_0',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 1)
            self.assertEqual(self.foreach.context.get('inst:current'), 'one')

    def test_handle_message_completed_from_non_last_child(self):
        """Test Foreach.handle_message() with complete msg from non last child.
        """

        msg = Message(name='completed', target='fake-id_0',
                      origin='fake-id_0_0')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.context._props["inst:iteration"] = 1
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start', target='fake-id_0_1',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_1',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 1)
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
            self.assertEqual(self.foreach.context.get("prop2"), 2)

    def test_handle_message_completed_from_last_child(self):
        """Test Foreach.handle_message() with complete msg from last child."""

        msg = Message(name='completed', target='fake-id_0',
                      origin='fake-id_0_1')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.children[0].state = 'completed'
        self.foreach.context._props["inst:iteration"] = 1
        self.foreach.context._props["inst:current"] = "one"
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        self.foreach.context.set("prop2", 10)
        self.foreach.context.set("prop3", 10)
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start', target='fake-id_0_1',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_0',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 2)
            self.assertEqual(self.foreach.context.get('inst:current'), 'two')
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
            self.assertEqual(self.foreach.context.get("prop2"), 2)
            self.assertEqual(self.foreach.context.get("prop3"), 2)

    def test_handle_message_last_completed(self):
        """Test Foreach.handle_message() with last complete msg."""

        msg = Message(name='completed', target='fake-id_0',
                      origin='fake-id_0_1')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.children[0].state = 'completed'
        self.foreach.children[1].state = 'completed'
        self.foreach.context._props["inst:iteration"] = 2
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='completed', target='fake-id',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'completed')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
Exemplo n.º 7
0
class TestForeach(unittest.TestCase):
    """Tests for Foreach activity."""
    def setUp(self):
        """Set up test case."""
        xml_element = ET.fromstring(procdsc)
        self.root = Process('', xml_element, 'fake-id', Context())
        self.foreach = self.root.children[0]
        self.ch = Mock()

    def test_handle_message_completed_state(self):
        """Test Foreach.handle_message() when Foreach is completed."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        self.foreach.state = 'completed'
        result = self.root.handle_message(self.ch, msg)
        self.assertEqual(result, 'ignored')

    def test_handle_message_wrong_target(self):
        """Test Foreach.handle_message() when message targeted not to it."""

        msg = Message(name='start', target='fake-id_10', origin='fake-id')
        self.root.state = 'active'
        self.foreach.state = 'active'
        result = self.root.handle_message(self.ch, msg)
        self.assertEqual(result, 'ignored')

    def test_handle_message_start_with_empty_select(self):
        """Test Foreach.handle_message() with start msg and empty select."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        self.root.context.set('prop2', {"subkey": []})
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='completed',
                             target='fake-id',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'completed')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_start(self):
        """Test Foreach.handle_message() with start msg."""

        msg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.root.state = 'active'
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start',
                             target='fake-id_0_0',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_0',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 1)
            self.assertEqual(self.foreach.context.get('inst:current'), 'one')

    def test_handle_message_completed_from_non_last_child(self):
        """Test Foreach.handle_message() with complete msg from non last child.
        """

        msg = Message(name='completed',
                      target='fake-id_0',
                      origin='fake-id_0_0')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.context._props["inst:iteration"] = 1
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start',
                             target='fake-id_0_1',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_1',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 1)
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
            self.assertEqual(self.foreach.context.get("prop2"), 2)

    def test_handle_message_completed_from_last_child(self):
        """Test Foreach.handle_message() with complete msg from last child."""

        msg = Message(name='completed',
                      target='fake-id_0',
                      origin='fake-id_0_1')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.children[0].state = 'completed'
        self.foreach.context._props["inst:iteration"] = 1
        self.foreach.context._props["inst:current"] = "one"
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        self.foreach.context.set("prop2", 10)
        self.foreach.context.set("prop3", 10)
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='start',
                             target='fake-id_0_1',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0_0',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.foreach.context.get('inst:iteration'), 2)
            self.assertEqual(self.foreach.context.get('inst:current'), 'two')
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
            self.assertEqual(self.foreach.context.get("prop2"), 2)
            self.assertEqual(self.foreach.context.get("prop3"), 2)

    def test_handle_message_last_completed(self):
        """Test Foreach.handle_message() with last complete msg."""

        msg = Message(name='completed',
                      target='fake-id_0',
                      origin='fake-id_0_1')
        self.root.state = 'active'
        self.foreach.state = 'active'
        self.foreach.children[0].state = 'completed'
        self.foreach.children[1].state = 'completed'
        self.foreach.context._props["inst:iteration"] = 2
        self.foreach.context._props["inst:selection"] = ["one", "two"]
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            newmsg = Message(name='completed',
                             target='fake-id',
                             origin='fake-id_0')
            MockMessage.return_value = newmsg
            result = self.root.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.foreach.state, 'completed')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)
            self.assertEqual(self.root.context.get("prop2"),
                             {"subkey": ["one", "two"]})
Exemplo n.º 8
0
class TestProcess(unittest.TestCase):
    """Tests for Process."""

    def setUp(self):
        xml_element = ET.fromstring(processdsc)
        self.fexpr = Process('', xml_element, 'fake-id', Context())
        self.ch = Mock()

    def test_handle_message_start(self):
        """Test Process.handle_message() with start message."""

        msg = Message(name='start', target='fake-id', origin='')
        newmsg = Message(name='start', target='fake-id_0', origin='fake-id')
        self.fexpr.state = 'ready'
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_0',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_completed1(self):
        """Test Process.handle_message() with completed msg from first child."""

        msg = Message(name='completed', target='fake-id', origin='fake-id_0')
        self.fexpr.state = 'active'
        newmsg = Message(name='start', target='fake-id_1', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='start',
                                                target='fake-id_1',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_completed2(self):
        """Test Process.handle_message() with completed msg from last child."""

        msg = Message(name='completed', target='fake-id', origin='fake-id_1')
        self.fexpr.state = 'active'
        newmsg = Message(name='completed', target='', origin='fake-id')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'completed')
            MockMessage.assert_called_once_with(name='completed', target='',
                                                origin='fake-id')
            self.ch.send.assert_called_once_with(newmsg)

    def test_handle_message_response(self):
        """Test Process.handle_message() with response msg for child."""

        msg = Message(name='response', target='fake-id_0', origin='fake-id_0',
                      payload={"status": "done"})
        self.fexpr.state = 'active'
        self.fexpr.children[0].state = 'active'
        newmsg = Message(name='completed', target='fake-id',
                         origin='fake-id_0')
        with patch('bureaucrat.flowexpression.Message') as MockMessage:
            MockMessage.return_value = newmsg
            result = self.fexpr.handle_message(self.ch, msg)
            self.assertEqual(result, 'consumed')
            self.assertEqual(self.fexpr.state, 'active')
            MockMessage.assert_called_once_with(name='completed',
                                                target='fake-id',
                                                origin='fake-id_0')
            self.ch.send.assert_called_once_with(newmsg)