def _package_source(build_script, description): files = [ plain_file("whack/whack.json", json.dumps(description)), sh_script_description("whack/build", build_script), ] with create_temporary_dir(files) as package_source_dir: yield PackageSource.local(package_source_dir)
def add_source(self, source_dir): package_source = PackageSource.local(source_dir) source_tarball = create_source_tarball(package_source, self._root) source_filename = os.path.relpath(source_tarball.path, self._root) source_url = self._http_server.static_url(source_filename) self._sources.append((source_filename, source_url)) self._generate_index() return source_tarball
def _get_package(self, params): target_dir = os.path.join(self._test_dir, str(uuid.uuid4())) package_source_dir = os.path.join(self._test_dir, str(uuid.uuid4())) package_provider = CachingPackageProvider( cacher=self._cacher, underlying_provider=self._underlying_provider, ) request = create_package_request(PackageSource.local(package_source_dir), params) package_provider.provide_package(request, target_dir)
def error_is_raised_if_build_script_is_missing(): files = [ plain_file("whack/whack.json", json.dumps({})), ] with create_temporary_dir(files) as package_source_dir: package_source = PackageSource.local(package_source_dir) request = create_package_request(package_source, {}) with create_temporary_dir() as target_dir: assert_raises( FileNotFoundError, ("whack/build script not found in package source {0}".format(package_source_dir), ), lambda: build(request, target_dir), )
def create_source(package_source_dir): package_source = PackageSource.local(package_source_dir) source_tarball = create_source_tarball(package_source, server.root) filename = os.path.relpath(source_tarball.path, server.root) return server.static_url(filename)
def _source_package_with_description(description): with create_temporary_dir() as package_source_dir: write_files(package_source_dir, [ plain_file("whack/whack.json", json.dumps(description)), ]) yield PackageSource.local(package_source_dir)
def name_of_package_source_is_unknown_if_whack_json_does_not_exist(): with create_temporary_dir() as package_source_dir: package_source = PackageSource.local(package_source_dir) assert_equal("unknown", package_source.name())
def fetch(self, package_name): return PackageSource.local(package_name)