'Test filtering based on gid happens correctly.'

def testGIDFilter(self):

    pathspec = rdf_paths.PathSpec(path='/mock2/', pathtype=rdf_paths.PathSpec.PathType.OS)
    request = rdf_client.FindSpec(pathspec=pathspec, path_regex='.', gid=500, cross_devs=True)
    request.iterator.number = 200
    result = self.RunAction(searching.Find, request)
    all_files = [x.hit for x in result if isinstance(x, rdf_client.FindSpec)]
    self.assertEqual(len(all_files), 2)
    self.assertEqual(all_files[0].pathspec.Dirname().Basename(), 'directory2')
    self.assertEqual(all_files[0].pathspec.Basename(), 'file.jpg')
    self.assertEqual(all_files[1].pathspec.Dirname().Basename(), 'directory2')
    self.assertEqual(all_files[1].pathspec.Basename(), 'file.mp3')
    request = rdf_client.FindSpec(pathspec=pathspec, path_regex='.', gid=900, cross_devs=True)
    request.iterator.number = 200
    result = self.RunAction(searching.Find, request)
    all_files = [x.hit for x in result if isinstance(x, rdf_client.FindSpec)]
    self.assertEqual(len(all_files), 2)
    self.assertEqual(all_files[0].pathspec.Dirname().Basename(), 'directory1')
    self.assertEqual(all_files[0].pathspec.Basename(), 'file1.txt')
    self.assertEqual(all_files[1].pathspec.Dirname().Basename(), 'directory1')
    self.assertEqual(all_files[1].pathspec.Basename(), 'file2.txt')
