def testAttrChangeAfterListing(self, listxattr): with test_lib.AutoTempFilePath() as temp_filepath: self._SetAttr(temp_filepath, "user.bar", "baz") attrs = list(client_utils_linux.GetExtAttrs(temp_filepath)) self.assertTrue(listxattr.called) self.assertEqual(len(attrs), 1) self.assertEqual(attrs[0].name, "user.bar") self.assertEqual(attrs[0].value, "baz")
def testAttrChangeAfterListing(self, listxattr): with temp.AutoTempFilePath() as temp_filepath: filesystem_test_lib.SetExtAttr( temp_filepath, name=b"user.bar", value=b"baz") attrs = list(client_utils_linux.GetExtAttrs(temp_filepath)) self.assertTrue(listxattr.called) self.assertLen(attrs, 1) self.assertEqual(attrs[0].name, b"user.bar") self.assertEqual(attrs[0].value, b"baz")
def testMany(self): with test_lib.AutoTempFilePath() as temp_filepath: self._SetAttr(temp_filepath, "user.foo", "bar") self._SetAttr(temp_filepath, "user.quux", "norf") attrs = list(client_utils_linux.GetExtAttrs(temp_filepath)) self.assertEqual(len(attrs), 2) self.assertEqual(attrs[0].name, "user.foo") self.assertEqual(attrs[0].value, "bar") self.assertEqual(attrs[1].name, "user.quux") self.assertEqual(attrs[1].value, "norf")
def testMany(self): with temp.AutoTempFilePath() as temp_filepath: filesystem_test_lib.SetExtAttr( temp_filepath, name=b"user.foo", value=b"bar") filesystem_test_lib.SetExtAttr( temp_filepath, name=b"user.quux", value=b"norf") attrs = list(client_utils_linux.GetExtAttrs(temp_filepath)) self.assertLen(attrs, 2) self.assertEqual(attrs[0].name, b"user.foo") self.assertEqual(attrs[0].value, b"bar") self.assertEqual(attrs[1].name, b"user.quux") self.assertEqual(attrs[1].value, b"norf")
def testIncorrectFilePath(self): attrs = list(client_utils_linux.GetExtAttrs("/foo/bar/baz/quux")) self.assertEqual(len(attrs), 0)
def testEmpty(self): with test_lib.AutoTempFilePath() as temp_filepath: attrs = list(client_utils_linux.GetExtAttrs(temp_filepath)) self.assertEqual(len(attrs), 0)