def test_add_package_force(): pkg1 = Package('test-0.0.1', ['foo']) pkg2 = Package('test-0.0.1', ['bar']) index = Index([pkg1]) index.add_package(pkg2, force=True) assert index.packages == {pkg2}
def test_add_package(): pkg1 = Package("test-0.0.1", ["foo"]) pkg2 = Package("test-0.0.2", ["bar"]) index = Index([pkg1]) index.add_package(pkg2) assert index.packages == {pkg1, pkg2}
def test_add_package(): pkg1 = Package('test-0.0.1', ['foo']) pkg2 = Package('test-0.0.2', ['bar']) index = Index([pkg1]) index.add_package(pkg2) assert index.packages == {pkg1, pkg2}
def test_add_package_force(): pkg1 = Package("test-0.0.1", ["foo"]) pkg2 = Package("test-0.0.1", ["bar"]) index = Index([pkg1]) index.add_package(pkg2, force=True) assert index.packages == {pkg2}
def test_add_package_exists(): pkg1 = Package('test-0.0.1', ['foo']) pkg2 = Package('test-0.0.1', ['bar']) index = Index([pkg1]) with pytest.raises(S3PyPiError): index.add_package(pkg2)
def test_add_package_exists(): pkg1 = Package("test-0.0.1", ["foo"]) pkg2 = Package("test-0.0.1", ["bar"]) index = Index([pkg1]) with pytest.raises(S3PyPiError): index.add_package(pkg2)
def test_add_package_force(): pkg1 = Package("test-0.0.1", ["foo"]) pkg2 = Package("test-0.0.1", ["bar"]) index = Index([pkg1]) index.add_package(pkg2, force=True) assert len(index.packages) == 1 assert next(iter(index.packages)).files == {"foo", "bar"}
def main(): p = argparse.ArgumentParser(prog=__prog__, version=__version__) p.add_argument('--bucket', required=True, help='S3 bucket') p.add_argument('--secret', help='S3 secret') p.add_argument('--region', choices=[ 'APNortheast', 'APSoutheast', 'APSoutheast2', 'DEFAULT', 'EU', 'EUCentral1', 'SAEast', 'USWest', 'USWest2' ], help='S3 Region') p.add_argument('--no-wheel', dest='wheel', action='store_false', help='Skip wheel distribution') args = p.parse_args() package = Package.create(args.wheel) storage = S3Storage(args.bucket, args.secret, args.region) index = storage.get_index(package) index.packages.discard(package) index.packages.add(package) storage.put_package(package) storage.put_index(package, index)
def create_and_upload_package(args): package = Package.create(args.wheel) storage = S3Storage(args.bucket, args.secret, args.region, args.bare) index = storage.get_index(package) index.add_package(package, args.force) storage.put_package(package) storage.put_index(package, index)
def create_and_upload_package(args): package = Package.create(args.wheel, args.sdist) storage = S3Storage(args.bucket, args.secret, args.region, args.bare, args.private, args.profile) index = storage.get_index(package) index.add_package(package, args.force) storage.put_package(package) storage.put_index(package, index)
def main(): p = argparse.ArgumentParser(prog=__prog__, version=__version__) p.add_argument('--bucket', required=True, help='S3 bucket') p.add_argument('--secret', help='S3 secret') p.add_argument('--region', choices=['APNortheast', 'APSoutheast', 'APSoutheast2', 'DEFAULT', 'EU', 'EUCentral1', 'SAEast', 'USWest', 'USWest2'], help='S3 Region') p.add_argument('--no-wheel', dest='wheel', action='store_false', help='Skip wheel distribution') args = p.parse_args() package = Package.create(args.wheel) storage = S3Storage(args.bucket, args.secret, args.region) index = storage.get_index(package) index.packages.discard(package) index.packages.add(package) storage.put_package(package) storage.put_index(package, index)
import pytest from s3pypi.package import Package @pytest.fixture(scope='function') def secret(): return ''.join( random.choice(string.ascii_letters + string.digits) for _ in range(24)) @pytest.fixture(scope='function', params=['helloworld-0.1', 's3pypi-0.1.3']) def sdist_output(request): with open(os.path.join('tests', 'data', 'sdist_output', request.param)) as f: yield f.read().encode('utf-8'), request.param @pytest.fixture( scope='function', params=[('s3pypi', { Package('s3pypi-' + v, {'s3pypi-%s.tar.gz' % v, 's3pypi-%s-py2-none-any.whl' % v}) for v in ('0.1.1', '0.1.2') })]) def index_html(request): name, packages = request.param with open(os.path.join('tests', 'data', 'index', name + '.html')) as f: yield f.read().strip().encode('utf-8'), packages
def test_find_wheel_name(bdist_wheel_output): stdout, expected_name = bdist_wheel_output assert Package._find_wheel_name(stdout) == expected_name
def test_directory_normalize_package_name(): pkg = Package("company.test-0.0.1", ["foo"]) assert pkg.directory == "company-test"
@pytest.fixture(scope="function", params=["hello-world-0.1.0"]) def wheel_metadata(request): with open(os.path.join("tests", "data", "wheel_metadata", request.param)) as f: yield f.read(), request.param @pytest.fixture( scope="function", params=[( "s3pypi", { Package( "s3pypi-" + v, {"s3pypi-%s.tar.gz" % v, "s3pypi-%s-py2-none-any.whl" % v}, ) for v in ( "0", "0!0", "0+local", "0.0", "0.1.1", "0.1.2", "0.dev0", "0.post0", "0a0", "0rc0", ) },
def test_directory_normalize_package_name(): pkg = Package('company.test-0.0.1', ['foo']) assert pkg.directory == 'company-test'
def test_secret_in_s3_key(secret): storage = S3Storage('appstrakt-pypi', secret) package = Package('test-0.1.0', []) assert secret in storage._object(package, 'index.html').key
def test_find_package_name(sdist_output): stdout, expected_name = sdist_output assert Package._find_package_name(stdout) == expected_name
def test_find_name_from_wheel_metadata(wheel_metadata): metadata, expected_name = wheel_metadata assert Package._find_name_from_wheel_metadata(metadata) == expected_name
def test_secret_in_s3_key(secret): storage = S3Storage("appstrakt-pypi", secret) package = Package("test-0.1.0", []) assert secret in storage._object(package, "index.html").key assert storage.acl == "public-read"