def test_get_data_file_size_dne_os_err(self): td = tempfile.mkdtemp() the_path = os.path.join(td, "vol0", "bar") the_file = os.path.join(the_path, "z") try: os.makedirs(the_path) with open(the_file, "wb") as fd: fd.write("1234") gdf = DiskFile(td, "vol0", "p57", "ufo47", "bar", "z", self.lg) assert gdf._obj == "z" assert gdf.data_file == the_file assert not gdf._is_dir gdf.data_file = gdf.data_file + ".dne" try: gdf.get_data_file_size() except DiskFileNotExist: pass else: self.fail("Expected DiskFileNotExist exception") finally: shutil.rmtree(td)
def test_is_deleted(self): assert not os.path.exists("/tmp/foo") gdf = DiskFile("/tmp/foo", "vol0", "p57", "ufo47", "bar", "z", self.lg) assert gdf.is_deleted() gdf.data_file = "/tmp/foo/bar" assert not gdf.is_deleted()