def test_creation_upper_dir(tmpdir, monkeypatch):
 from wal_e import pipebuf
 adir = tmpdir.join('adir').ensure(dir=True)
 some_file = adir.join('afile')
 some_file.write('1234567890')
 tar_path = str(tmpdir.join('foo.tar'))
 tar = tarfile.open(name=tar_path, mode='w')
 tar.add(str(some_file))
 tar.close()
 original_cat_extract = tar_partition.cat_extract
 class CheckCatExtract(object, ):
  def __init__(self):
   self.called = False
  def __call__(self, *args, **kwargs):
   self.called = True
   return original_cat_extract(*args, **kwargs)
 check = CheckCatExtract()
 monkeypatch.setattr(tar_partition, 'cat_extract', check)
 monkeypatch.setattr(pipebuf, 'PIPE_BUF_BYTES', 1)
 dest_dir = tmpdir.join('dest')
 dest_dir.ensure(dir=True)
 with open(tar_path, 'rb') as f:
  tar_partition.TarPartition.tarfile_extract(f, str(dest_dir))
 assert check.called

def test_creation_upper_dir ( tmpdir , monkeypatch ) : from wal_e import pipebuf adir = tmpdir . join ( 'adir' ) . ensure ( dir = True ) some_file = adir . join ( 'afile' ) some_file . write ( '1234567890' ) tar_path = str ( tmpdir . join ( 'foo.tar' ) ) tar = tarfile . open ( name = tar_path , mode = 'w' ) tar . add ( str ( some_file ) ) tar . close ( ) original_cat_extract = tar_partition . cat_extract class CheckCatExtract ( object , ) : def __init__ ( self ) : self . called = False def __call__ ( self , * args , ** kwargs ) : self . called = True return original_cat_extract ( * args , ** kwargs ) check = CheckCatExtract ( ) monkeypatch . setattr ( tar_partition , 'cat_extract' , check ) monkeypatch . setattr ( pipebuf , 'PIPE_BUF_BYTES' , 1 ) dest_dir = tmpdir . join ( 'dest' ) dest_dir . ensure ( dir = True ) with open ( tar_path , 'rb' ) as f : tar_partition . TarPartition . tarfile_extract ( f , str ( dest_dir ) ) assert check . called
check for upper-directory creation in untarring this affected the special "cat" based extraction works when no upper level directory is present .