コード例 #1
0
 def test_tar_no_permissions(self):
     tmpdir = tempfile.mkdtemp()
     try:
         with pytest.raises(IOError) as ex:
             wagon._tar(tmpdir, '/file')
         assert "Permission denied" in str(ex.value)
         assert "/file" in str(ex.value)
     finally:
         shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #2
0
 def test_tar_missing_source(self):
     with pytest.raises(OSError) as ex:
         wagon._tar('missing', 'file')
     if wagon.IS_WIN:
         assert "The system cannot find the file specified: 'missing'" \
             in str(ex.value)
     else:
         assert "No such file or directory" in str(ex.value)
         assert "missing" in str(ex.value)
     os.remove('file')
コード例 #3
0
 def test_tar(self):
     tempdir = tempfile.mkdtemp()
     with open(os.path.join(tempdir, 'content.file'), 'w') as f:
         f.write('CONTENT')
     wagon._tar(tempdir, 'tar.file')
     shutil.rmtree(tempdir, ignore_errors=True)
     assert tarfile.is_tarfile('tar.file')
     with closing(tarfile.open('tar.file', 'r:gz')) as tar:
         members = tar.getnames()
         dirname = os.path.split(tempdir)[1]
         assert '{0}/content.file'.format(dirname) in members
     os.remove('tar.file')
コード例 #4
0
 def test_fail_validation_exclude_and_missing_wheel(self):
     test_package = os.path.join('tests', 'resources', 'test-package')
     requirement_files = [os.path.join(test_package, 'requirements.txt')]
     archive_path = wagon.create(source=test_package,
                                 requirement_files=requirement_files,
                                 force=True)
     archive_name = os.path.basename(archive_path)
     tempdir = tempfile.mkdtemp()
     try:
         wagon._unzip(archive_name, tempdir)
         wheels_dir = os.path.join(tempdir, 'test-package',
                                   wagon.DEFAULT_WHEELS_PATH)
         for wheel in os.listdir(wheels_dir):
             if wheel.startswith('wheel'):
                 break
         wheel_to_delete = os.path.join(wheels_dir, wheel)
         os.remove(wheel_to_delete)
         wagon._tar(os.path.join(tempdir, 'test-package'), archive_name)
         result = wagon.validate(archive_name)
         assert len(result) == 1
     finally:
         shutil.rmtree(tempdir, ignore_errors=True)
         if os.path.isfile(archive_name):
             os.remove(archive_name)