'Ensure we can extract users from a passwd file.'

def testPasswdParser(self):

    parser = linux_file_parser.PasswdParser()
    dat = '\nuser1:x:1000:1000:User1    Name,,,:/home/user1:/bin/bash\nuser2:x:1001:1001:User2    Name,,,:/home/user2:/bin/bash\n'
    out = list(parser.Parse(None, StringIO.StringIO(dat), None))
    self.assertEqual(len(out), 2)
    self.assertTrue(isinstance(out[1], rdf_client.User))
    self.assertTrue(isinstance(out[1], rdf_client.User))
    self.assertEqual(out[0].username, 'user1')
    self.assertEqual(out[0].full_name, 'User1    Name,,,')
    dat = '\nuser1:x:1000:1000:User1    Name,,,:/home/user1:/bin/bash\nuser2:x:1001:1001:User2    Name,,,:/home/user\n'
    parser = linux_file_parser.PasswdParser()
    self.assertRaises(parsers.ParseError, list, parser.Parse(None, StringIO.StringIO(dat), None))
