def test_waiting_simple(self):
        """Test SyncDaemonTool.waiting."""
        # inject the fake data
        c1 = FakeCommand("node_a_foo", "node_a_bar", path='path')
        c2 = FakeCommand("node_b_foo", "node_b_bar")
        c2.running = False
        self.action_q.queue.waiting.extend([c1, c2])
        result = yield self.tool.waiting()

        self.assertEqual(2, len(result))

        pl = dict(share_id='node_a_foo', node_id='node_a_bar',
                  other='', path='path', running='True')
        self.assertEqual(result[0], ('FakeCommand', str(id(c1)), pl))

        pl = dict(share_id='node_b_foo', node_id='node_b_bar',
                  other='', running='')
        self.assertEqual(result[1], ('FakeCommand', str(id(c2)), pl))
    def test_show_waiting_simple(self):
        """Test the output of --waiting-metadata"""
        # inject the fake data
        cmd1 = FakeCommand("", "node1", path='foo')
        cmd1.running = True
        cmd2 = FakeCommand("", "node2")
        cmd2.running = False
        self.action_q.queue.waiting.extend([cmd1, cmd2])

        out = StringIO()
        expected = (
            "  FakeCommand(running=True, share_id='', node_id='node1', "
            "path='foo', other='')\n"
            "  FakeCommand(running=False, share_id='', node_id='node2', "
            "other='')\n"
        )

        result = yield self.tool.waiting()
        show_waiting(result, out)
        self.assertEqual(out.getvalue(), expected)
 def __init__(self, *args, **kwargs):
     FakeCommand.__init__(self, *args, **kwargs)