def test_files_from_tar_empty_basepath(self): tar = os.path.join(self.data_path, 'test.tar') files = files_from_tar('', tar) self.eq( sorted((x.path, x.view, x.kwargs['member']) for x in files), [ ('static/file.txt', file_from_tar, 'static/file.txt'), ('static/other.txt', file_from_tar, 'static/other.txt'), ], )
def test_files_from_tar_strip(self): tar = os.path.join(self.data_path, 'test.tar') files = files_from_tar('foo', tar, strip=1) self.eq( sorted((x.path, x.view, x.kwargs['member']) for x in files), [ ('foo/file.txt', file_from_tar, 'static/file.txt'), ('foo/other.txt', file_from_tar, 'static/other.txt'), ], )
def test_file_from_tar(self): # stango.files.files_from_dir uses the stango.views.file_from_tar view tar = os.path.join(self.data_path, 'test.tar') self.manager.files += files_from_tar('foo', tar) self.manager.generate(self.tmp) self.eq(filelist(self.tmp), [ 'foo/static/file.txt', 'foo/static/other.txt', ]) with open(os.path.join(self.tmp, 'foo/static/file.txt')) as fobj: self.eq(fobj.read(), 'This is a test file\n') with open(os.path.join(self.tmp, 'foo/static/other.txt')) as fobj: self.eq(fobj.read(), 'This is also a test file\n')
def test_file_from_tar(self): # stango.files.files_from_dir uses the stango.views.file_from_tar view tar = os.path.join(self.data_path, 'test.tar') self.manager.files += files_from_tar('foo', tar) self.manager.generate(self.tmp) self.eq( filelist(self.tmp), [ 'foo/static/file.txt', 'foo/static/other.txt', ] ) with open(os.path.join(self.tmp, 'foo/static/file.txt')) as fobj: self.eq(fobj.read(), 'This is a test file\n') with open(os.path.join(self.tmp, 'foo/static/other.txt')) as fobj: self.eq(fobj.read(), 'This is also a test file\n')