def test_sane_defaults(self, source_fs): # pylint: disable=unused-argument, no-self-use packer = Packager('zip.zip') assert not packer.keep # pylint: disable=len-as-condition assert len(packer.build_path) > 0 assert os.path.isabs(packer.build_path)
def test_keeps(self, source_fs): # pylint: disable=unused-argument, no-self-use build_path = '/home/foo/tmp/build' packer = Packager('zip.zip', build_path, True) packer.package() packer.clean() assert os.path.exists(build_path)
def test_zip_target_locations(self, cwd, target, expected, source_fs, fileset): # pylint: disable=unused-argument,no-self-use,too-many-arguments os.chdir(cwd) packager = Packager(zip_file=target) packager.add_fileset_items(fileset) packager.package() assert os.path.exists(expected) assert os.path.isfile(expected)
def entry_point(): # Only here to be quiet and dump out the config. Have to do this before # activating logging. if '--generate-config' in sys.argv[1:]: Configuration.print_default_config() sys.exit(0) # General configuration setup_logging() cli_args = parse_args(sys.argv[1:]) config = Configuration(vars(cli_args)) cwd = os.getcwd() # Information for the VirtualEnv pip_requirements = config.data['virtualenv']['pip']['requirements'] fileset_excludes = config.data['virtualenv']['default_excludes'] # Information for the PyLambdaPacker filesets = [] if config.data['packager']['includes']: filesets = [ FileSet(cwd, includes=config.data['packager']['includes'], excludes=config.data['packager']['excludes'] + config.data['packager']['default_excludes']) ] # Build! with VirtualEnv(python=config.data['virtualenv']['python'], path=config.data['virtualenv']['path'], keep=config.data['virtualenv']['keep'], packages=config.data['virtualenv']['pip']['packages'], requirements=pip_requirements, fileset_excludes=fileset_excludes) as virtual_env, \ Packager( zip_file=config.data['packager']['target'], build_path=config.data['packager']['build_path'], keep=config.data['packager']['keep']) as packager: packer = PyLambdaPacker(virtual_env, packager, filesets) packer.build()
def packager(source_fs): # pylint: disable=unused-argument,redefined-outer-name os.chdir('/home/foo/src/bar-project') return Packager('zip.zip')
def test_uses_default_dir(self, source_fs): # pylint: disable=unused-argument, no-self-use packer = Packager('zip.zip', keep=True) packer.package() packer.clean() assert os.path.exists(packer.build_path)
def test_error_on_existing_build_dir(self, source_fs): # pylint: disable=unused-argument, no-self-use # pylint: disable=invalid-name build_path = '/home/foo/tmp' with pytest.raises(OSError): Packager('zip.zip', build_path)
def test_creates_build_dir(self, source_fs): # pylint: disable=unused-argument, no-self-use build_path = '/home/foo/tmp/build' packer = Packager('zip.zip', build_path) assert os.path.exists(packer.build_path)
def test_with(self, source_fs): # pylint: disable=unused-argument, no-self-use with Packager('zip.zip') as packer: assert os.path.exists(packer.build_path) assert not os.path.exists(packer.build_path)