Пример #1
0
 def test_propertyFreeFile(self):
     """
     Not all files have extended attributes or the associated AppleDouble
     file.  Make sure that retrieving the 'attrs' attribute yields an empty
     dictionary in that case.
     """
     sample = FilePath(self.mktemp())
     sample.setContent("")
     props = PropertyStore("nobody", lambda: sample)
     self.assertEqual(props.attrs, {})
Пример #2
0
    def test_propertiesFromTarball(self):
        """
        Extracting a tarball with included AppleDouble WebDAV property
        information should allow properties to be retrieved using
        L{PropertyStore}.
        """
        tf = TarFile.gzopen('sample.tgz', fileobj=StringIO(samplePropertyTar))
        tmpdir = self.mktemp()

        # Note that 'tarfile' doesn't know anything about xattrs, so while OS
        # X's 'tar' will restore these as actual xattrs, the 'tarfile' module
        # will drop "._" parallel files into the directory structure on all
        # platforms.
        tf.extractall(tmpdir)

        props = PropertyStore("bob", lambda: FilePath(tmpdir).child('f'))

        self.assertEqual(props[PropertyName.fromElement(HRef)],
                         HRef("http://sample.example.com/"))
        self.assertEqual(props[PropertyName.fromElement(Depth)], Depth("1"))
        self.assertEqual(props[PropertyName.fromElement(GETContentType)],
                         GETContentType("text/example"))