def test_file(self): try: fsm = FSManager(temporary=True) fsm.mkfile(alias="rambo", path="test/test1") if fsm.file("rambo") is None: raise Exception("Couldn't find a file") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_mv_file_path(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.mv("rambo", "mambo", "test1/test22/test33") if not (fsm.file("mambo") is not None and os.path.exists( os.path.join(fsm.prefix_path, "test1/test22/test33"))): raise Exception("File hasn't been moved") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_cp_file_alias(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.cp("rambo", "test1/test22/test33") if not (fsm.file("test1/test22/test33") is not None and fsm.exists("test1/test22/test33")): raise Exception("File hasn't been copied") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_chmod_file(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.chmod("rambo", 0o644) if oct(os.stat(fsm.file("rambo").path).st_mode & 0o777) != oct(0o644): raise Exception("Wrong mode of file") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_mv_file_alias(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.mv("rambo", "test1/test22/test33") if not (fsm.file("test1/test22/test33") is not None and fsm.exists("test1/test22/test33")): raise Exception("File hasn't been moved") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_chmod_file(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.chmod("rambo", 0o644) if oct(os.stat(fsm.file("rambo").path). st_mode & 0o777) != oct(0o644): raise Exception("Wrong mode of file") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_open(self): try: fsm = FSManager(temporary=True) fsm.mkfile(alias="rambo", path="test/test1") with fsm.open("rambo", "w") as f: f.write("rambo test") with open(fsm.file("rambo").path) as f: if f.readline() != "rambo test": raise Exception("Couldn't write to file") except Exception as exc: traceback.print_exc() self.fail(exc)
def test_cp_file_path(self): try: fsm = FSManager(temporary=True) fsm.mkfile("rambo", "test1/test2/test3") fsm.cp("rambo", "mambo", "test1/test22/test33") if not (fsm.file("mambo") is not None and os.path.exists(os.path.join(fsm.prefix_path, "test1/test22/test33"))): raise Exception("File hasn't been copied") except Exception as exc: traceback.print_exc() self.fail(exc)