def test_builder_simple_with_multi_meta_field(): manifest = build( BASE_MANIFEST, authors("some", "guy"), license("MIT"), description("description"), keywords("awesome", "package"), links(website="www", repository="github"), validate(), ) expected = assoc( BASE_MANIFEST, "meta", { "license": "MIT", "authors": ["some", "guy"], "description": "description", "keywords": ["awesome", "package"], "links": { "website": "www", "repository": "github" }, }, ) assert manifest == expected
def gen_authors() -> Optional[Callable[..., Manifest]]: flag = parse_bool_flag("Would you like to add authors to your package?") if flag: authors = input( "Enter an author, or multiple authors separated by commas: ") return b.authors(*[author.strip() for author in authors.split(",")]) return None
def amend_authors(manifest: Manifest) -> Optional[Callable[..., Manifest]]: try: authors = manifest["meta"]["authors"] except KeyError: flag = parse_bool_flag("No authors found, would you like to add any?") else: flag = parse_bool_flag( f"Authors found ({authors}). Would you like to change them?" ) if flag: new_authors = input("Enter an author or multiple authors separated by commas: ") return b.authors(*[author.strip() for author in new_authors.split(",")]) return None
def test_builder_with_init_manifest(owned_package, dummy_ipfs_backend): root, expected_manifest, compiler_output = owned_package ipfs_backend = get_ipfs_backend() manifest = build( init_manifest(package_name="owned", version="1.0.0"), authors("Piper Merriam <*****@*****.**>"), description( "Reusable contracts which implement a privileged 'owner' model for authorization." ), keywords("authorization"), license("MIT"), links(documentation= "ipfs://QmUYcVzTfSwJoigggMxeo2g5STWAgJdisQsqcXHws7b1FW"), pin_source("Owned", compiler_output, ipfs_backend, root), validate(), ) assert manifest == expected_manifest
def test_builder_with_manifest_validation(): with pytest.raises(ValidationError, match="_invalid_package_name"): build( {}, package_name("_invalid_package_name"), manifest_version("2"), version("1.0.0"), validate(), ) @pytest.mark.parametrize( "fn,value", ( (authors("some", "guy"), { "authors": ["some", "guy"] }), (license("MIT"), { "license": "MIT" }), (description("This is a package."), { "description": "This is a package." }), (keywords("awesome", "package"), { "keywords": ["awesome", "package"] }), ( links(documentation="ipfs..", website="www"), { "links": {