Exemple #1
0
def _deploy_package(file_descriptions):
    package_dir = tempfile.mkdtemp()
    try:
        write_files(package_dir, file_descriptions)
        deployer = PackageDeployer()
        deployer.deploy(package_dir)
        return DeployedPackage(package_dir)
    except:
        shutil.rmtree(package_dir)
        raise
Exemple #2
0
def writing_source_raises_error_if_file_is_missing():
    with create_temporary_dir() as package_source_dir:
        whack_description = {
            "sourcePaths": ["name"]
        }
        write_files(package_source_dir, [
            plain_file("whack/whack.json", json.dumps(whack_description)),
        ])
        
        with _fetch_source(package_source_dir) as package_source:
            with create_temporary_dir() as target_dir:
                assert_raises(
                    FileNotFoundError,
                    lambda: package_source.write_to(target_dir)
                )
Exemple #3
0
def writing_package_source_includes_directories_specified_in_description():
    with create_temporary_dir() as package_source_dir:
        whack_description = {
            "sourcePaths": ["names"]
        }
        write_files(package_source_dir, [
            plain_file("whack/whack.json", json.dumps(whack_description)),
            plain_file("names/bob", "Bob"),
        ])
        
        with _fetch_source(package_source_dir) as package_source:
            with create_temporary_dir() as target_dir:
                package_source.write_to(target_dir)
                assert_equal(
                    "Bob",
                    read_file(os.path.join(target_dir, "names/bob"))
                )
Exemple #4
0
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)