'Test that glob works properly.'

def testGlob(self):

    client = aff4.FACTORY.Open(self.client_id, mode='rw', token=self.token)
    kb = client.Get(client.Schema.KNOWLEDGE_BASE)
    kb.MergeOrAddUser(rdf_client.User(username='test'))
    kb.MergeOrAddUser(rdf_client.User(username='syslog'))
    client.Set(kb)
    client.Close()
    client_mock = action_mocks.GlobClientMock()
    paths = [os.path.join(self.base_path, '%%Users.username%%*'), os.path.join(self.base_path, 'VFSFixture/var/*/wtmp')]
    with utils.Stubber(filesystem.Glob, 'FILE_MAX_PER_DIR', 2):
        for _ in flow_test_lib.TestFlowHelper(filesystem.Glob.__name__, client_mock, client_id=self.client_id, paths=paths, pathtype=rdf_paths.PathSpec.PathType.OS, token=self.token, sync=False, check_flow_errors=False):
            pass
    output_path = self.client_id.Add('fs/os').Add(self.base_path.replace('\\', '/'))
    children = []
    fd = aff4.FACTORY.Open(output_path, token=self.token)
    for child in fd.ListChildren():
        filename = child.Basename()
        if (filename != 'VFSFixture'):
            children.append(filename)
    expected = [filename for filename in os.listdir(self.base_path) if (filename.startswith('test') or filename.startswith('syslog'))]
    self.assertTrue([x for x in expected if x.startswith('test')], "Need    a    file    starting    with    'test'    in    test_data    for    this    test!")
    self.assertTrue([x for x in expected if x.startswith('syslog')], "Need    a    file    starting    with    'syslog'    in    test_data    for    this    test!")
    self.assertItemsEqual(expected, children)
    children = []
    fd = aff4.FACTORY.Open(output_path.Add('VFSFixture/var/log'), token=self.token)
    for child in fd.ListChildren():
        children.append(child.Basename())
    self.assertItemsEqual(children, ['wtmp'])
