コード例 #1
0
ファイル: downloads_test.py プロジェクト: mwilliamson/whack
def downloader_can_download_files_over_http():
    downloader = Downloader(NoCachingStrategy())
    
    with create_temporary_dir() as server_root:
        files.write_file(os.path.join(server_root, "hello"), "Hello there!")
        with httpserver.start_static_http_server(server_root) as http_server:
            with create_temporary_dir() as download_dir:
                download_path = os.path.join(download_dir, "file")
                url = http_server.static_url("hello")
                downloader.download(url, download_path)
                assert_equal("Hello there!", files.read_file(download_path))
コード例 #2
0
ファイル: sources_tests.py プロジェクト: mwilliamson/whack
def _assert_package_source_can_be_written_to_target_dir(source_filter, indices=None):
    with _create_temporary_package_source_dir() as package_source_dir:
        package_source_name = source_filter(package_source_dir)
        
        with _fetch_source(package_source_name, indices) 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, "whack/name"))
                )
コード例 #3
0
ファイル: sources_tests.py プロジェクト: mwilliamson/whack
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"))
                )
コード例 #4
0
ファイル: builder_tests.py プロジェクト: mwilliamson/whack
def explicit_params_override_default_params():
    description = {"defaultParams": {"version": "42"}}
    with _package_source("echo $VERSION > $1/version", description) as package_source:
        with create_temporary_dir() as target_dir:
            build(create_package_request(package_source, {"version": "43"}), target_dir)
            assert_equal("43\n", read_file(os.path.join(target_dir, "version")))
コード例 #5
0
ファイル: builder_tests.py プロジェクト: mwilliamson/whack
def build_uses_default_value_for_param_if_param_not_explicitly_set():
    description = {"defaultParams": {"version": "42"}}
    with _package_source("echo $VERSION > $1/version", description) as package_source:
        with create_temporary_dir() as target_dir:
            build(create_package_request(package_source, {}), target_dir)
            assert_equal("42\n", read_file(os.path.join(target_dir, "version")))
コード例 #6
0
ファイル: builder_tests.py プロジェクト: mwilliamson/whack
def build_uses_params_as_environment_variables_in_build():
    with _package_source("echo $VERSION > $1/version", {}) as package_source:
        with create_temporary_dir() as target_dir:
            build(create_package_request(package_source, {"version": "42"}), target_dir)
            assert_equal("42\n", read_file(os.path.join(target_dir, "version")))