Beispiel #1
0
  def testExtAttrsCollection(self):
    with temp.AutoTempDirPath(remove_non_empty=True) as temp_dirpath:
      foo_filepath = temp.TempFilePath(dir=temp_dirpath)
      client_test_lib.SetExtAttr(foo_filepath, name="user.quux", value="foo")

      bar_filepath = temp.TempFilePath(dir=temp_dirpath)
      client_test_lib.SetExtAttr(bar_filepath, name="user.quux", value="bar")

      baz_filepath = temp.TempFilePath(dir=temp_dirpath)
      client_test_lib.SetExtAttr(baz_filepath, name="user.quux", value="baz")

      request = rdf_client_fs.FindSpec(
          pathspec=rdf_paths.PathSpec(
              path=temp_dirpath, pathtype=rdf_paths.PathSpec.PathType.OS),
          path_glob="*",
          collect_ext_attrs=True)
      request.iterator.number = 100

      hits = []
      for response in self.RunAction(searching.Find, request):
        if isinstance(response, rdf_client_fs.FindSpec):
          hits.append(response.hit)

      self.assertEqual(len(hits), 3)

      values = []
      for hit in hits:
        self.assertEqual(len(hit.ext_attrs), 1)
        values.append(hit.ext_attrs[0].value)

      self.assertItemsEqual(values, ["foo", "bar", "baz"])
Beispiel #2
0
  def testGetAllFiles(self):
    with temp.AutoTempDirPath(remove_non_empty=True) as tmpdir_path:
      foo_path = temp.TempFilePath(suffix="foo.yaml")
      bar_path = temp.TempFilePath(suffix="bar.json")
      baz_path = temp.TempFilePath(suffix="baz.yaml")
      quux_path = temp.TempFilePath(dir=tmpdir_path, suffix="quux.yaml")
      norf_path = temp.TempFilePath(dir=tmpdir_path, suffix="norf.json")
      thud_path = temp.TempFilePath(dir=tmpdir_path, suffix="thud.xml")

      self.sources.AddFile(foo_path)
      self.sources.AddFile(bar_path)
      self.sources.AddDir(tmpdir_path)

      files = list(self.sources.GetAllFiles())
      self.assertIn(foo_path, files)
      self.assertIn(bar_path, files)
      self.assertIn(quux_path, files)
      self.assertIn(norf_path, files)
      self.assertNotIn(baz_path, files)
      self.assertNotIn(thud_path, files)
Beispiel #3
0
 def setUp(self):
     super(FileReaderTest, self).setUp()
     self.temp_filepath = temp.TempFilePath()
Beispiel #4
0
 def setUp(self):
     super(StreamFilePathTest, self).setUp()
     self.temp_filepath = temp.TempFilePath()
Beispiel #5
0
 def setUp(self):
   super(ConditionTestMixin, self).setUp()
   self.temp_filepath = temp.TempFilePath()