本文整理汇总了Python中pmaker.models.FileObjectFactory类的典型用法代码示例。如果您正苦于以下问题:Python FileObjectFactory类的具体用法?Python FileObjectFactory怎么用?Python FileObjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileObjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__other
def test__other(self):
_path = "/dev/null"
if not os.path.exists(_path):
logging.warn("%s does not exist. Skip this test." % _path)
st_mode = Factory.lstat(_path)[0]
self.assertEquals(Factory.guess_filetype(st_mode), G.TYPE_OTHER)
示例2: open
def test_02_list__multi_generated_file(self):
listfile = os.path.join(self.workdir, "file.list")
listfile2 = os.path.join(self.workdir, "file2.list")
config = init_config(listfile)
line = "%s/file*.list\n" % self.workdir
open(listfile, "w").write(line)
open(listfile2, "w").write(line)
collector = FilelistCollector(listfile, config)
fos = collector.list(listfile)
fos_ref = [Factory.create(listfile), Factory.create(listfile2)]
self.assertEquals(sorted(fos), sorted(fos_ref))
示例3: test_update
def test_update(self):
modifier = RpmAttributeModifier()
f = F.create("/bin/bash")
new_f = modifier.update(f)
self.assertTrue(getattr(new_f, "rpm_attr", False))
示例4: test__symlink_missing
def test__symlink_missing(self):
fo = B.Bunch(path=self.missinglink)
fo = Factory.create_from_real_object(fo)
self.assertTrue(isinstance(fo, FO.SymlinkObject))
self.assertEquals(fo.type(), G.TYPE_SYMLINK)
self.assertEquals(fo.path, self.missinglink)
示例5: test__file_w_mode
def test__file_w_mode(self):
mode = "0600"
fo = B.Bunch(path=self.file, mode=mode)
fo = Factory.create_from_real_object(fo)
self.assertEquals(fo.mode, mode)
示例6: test_copy__exists
def test_copy__exists(self):
fo = Factory.create(self.testfile1)
dest = self.testfile1 + ".2"
FileOps.copy(fo, dest)
self.assertFalse(FileOps.copy(fo, dest))
示例7: test__dir_wo_metadata
def test__dir_wo_metadata(self):
fo = B.Bunch(path=self.dir)
fo = Factory.create_from_real_object(fo)
self.assertTrue(isinstance(fo, FO.DirObject))
self.assertEquals(fo.type(), G.TYPE_DIR)
self.assertEquals(fo.path, self.dir)
self.assertEquals(fo.mode, self.dir_mode)
示例8: test_pred__not_exist
def test_pred__not_exist(self):
filter = NotExistFilter()
path = "/bin/sh"
assert os.path.exists(path)
fo = Factory.create(path)
self.assertFalse(filter.pred(fo))
示例9: test__file_wo_metadata
def test__file_wo_metadata(self):
fo = B.Bunch(path=self.file)
fo = Factory.create_from_real_object(fo)
self.assertTrue(isinstance(fo, FO.FileObject))
self.assertEquals(fo.type(), G.TYPE_FILE)
self.assertEquals(fo.path, self.file)
self.assertEquals(fo.mode, self.file_mode)
示例10: test__file_w_uid_and_gid
def test__file_w_uid_and_gid(self):
uid = 1
gid = 1
fo = B.Bunch(path=self.file, uid=uid, gid=gid)
fo = Factory.create_from_real_object(fo)
self.assertEquals(fo.uid, uid)
self.assertEquals(fo.gid, gid)
示例11: test__create_wo_attrs
def test__create_wo_attrs(self):
fo = Factory.create(self.path)
self.assertTrue(isinstance(fo, FO.DirObject))
self.assertEquals(fo.mode, fo.defaults.mode)
self.assertEquals(fo.uid, fo.defaults.uid)
self.assertEquals(fo.gid, fo.defaults.gid)
self.assertEquals(fo.checksum, fo.defaults.checksum)
self.assertEquals(fo.path, self.path)
示例12: test_pred__unsupported__fileobjects
def test_pred__unsupported__fileobjects(self):
username = pwd.getpwuid(os.getuid()).pw_name
paths = ["/dev/null", "/dev/zero"] + glob.glob("/tmp/orbit-%s/linc-*" % username)[:3] # device files # socket
paths = [p for p in paths if os.path.exists(p)]
for p in paths:
fo = Factory.create(p)
self.assertTrue(self.filter.pred(fo))
示例13: test_copy_impl_and_remove
def test_copy_impl_and_remove(self):
fo = Factory.create(self.testfile1)
dest = self.testfile1 + ".2"
FileOps.copy_impl(fo, dest)
self.assertTrue(os.path.exists(dest))
FileOps.remove(dest)
self.assertFalse(os.path.exists(dest))
示例14: test_pred__permitted_to_read
def test_pred__permitted_to_read(self):
filter = ReadAccessFilter()
pred = lambda f: os.path.exists(f) and os.access(f, os.R_OK)
path = random.choice([p for p in ("/etc/hosts", "/etc/resolv.conf",
"/etc/sysctl.conf")
if pred(p)])
fo = Factory.create(path)
self.assertFalse(filter.pred(fo))
示例15: test__dir_w_mode
def test__dir_w_mode(self):
mode = "0700"
fo = B.Bunch(path=self.dir, mode=mode)
fo = Factory.create_from_real_object(fo)
self.assertTrue(isinstance(fo, FO.DirObject))
self.assertEquals(fo.type(), G.TYPE_DIR)
self.assertEquals(fo.path, self.dir)
self.assertEquals(fo.mode, mode)