'Test basic CLI commands (help, nodes, net, dump)'

def testBasic(self):

    p = pexpect.spawn('mn')
    p.expect(self.prompt)
    p.sendline('help')
    index = p.expect(['commands', self.prompt])
    self.assertEqual(index, 0, 'No    output    for    "help"    command')
    p.sendline('nodes')
    p.expect('([chs]\\d    ?){4}')
    nodes = p.match.group(0).split()
    self.assertEqual(len(nodes), 4, 'No    nodes    in    "nodes"    command')
    p.expect(self.prompt)
    p.sendline('net')
    expected = [x for x in nodes]
    while (len(expected) > 0):
        index = p.expect(expected)
        node = p.match.group(0)
        expected.remove(node)
        p.expect('\n')
    self.assertEqual(len(expected), 0, '"nodes"    and    "net"    differ')
    p.expect(self.prompt)
    p.sendline('dump')
    expected = [('<\\w+    (%s)' % n) for n in nodes]
    actual = []
    for _ in nodes:
        index = p.expect(expected)
        node = p.match.group(1)
        actual.append(node)
        p.expect('\n')
    self.assertEqual(actual.sort(), nodes.sort(), '"nodes"    and    "dump"    differ')
    p.expect(self.prompt)
    p.sendline('exit')
    p.wait()
