extends GutTest ## Attribution. Two of the packs this game ships are CC BY 4.0, which requires ## credit -- so these are licence-compliance tests, not tidiness ones. func test_every_source_is_completely_described() -> void: for entry in Credits.SOURCES: for field in ["name", "author", "licence", "url", "used_for"]: assert_false(String(entry[field]).strip_edges().is_empty(), "%s has no %s" % [entry.get("name", "?"), field]) assert_true(String(entry["url"]).begins_with("http"), "%s has no usable link" % entry["name"]) ## The whole point of the flag: it marks the entries a licence obliges us to ## show, as opposed to the ones credited because the work deserves it. func test_the_cc_by_packs_are_marked_as_required() -> void: var required := Credits.required() assert_gt(required.size(), 0) for entry in Credits.SOURCES: var is_cc_by := String(entry["licence"]).begins_with("CC BY") assert_eq(bool(entry["required"]), is_cc_by, "%s is %s but marked required=%s" % [ entry["name"], entry["licence"], entry["required"]]) ## CC BY asks for a link to the licence itself, not only to the work. A player ## reading the in-game screen has no other way to reach the terms. func test_every_creative_commons_licence_links_to_its_terms() -> void: for entry in Credits.SOURCES: var licence := String(entry["licence"]) if not licence.begins_with("CC"): continue assert_true(Credits.licence_url(licence).begins_with( "https://creativecommons.org/"), "%s has no link to its terms" % licence) ## The repository file and the in-game screen have to say the same thing. They ## are maintained separately, so this is what stops one of them going stale -- ## and a stale attribution is a licence problem, not a documentation one. func test_the_credits_file_names_every_source() -> void: var f := FileAccess.open("res://CREDITS.md", FileAccess.READ) assert_not_null(f, "CREDITS.md should be readable") var text := f.get_as_text() f.close() for entry in Credits.SOURCES: assert_true(text.contains(String(entry["name"])), "CREDITS.md never mentions %s" % entry["name"]) assert_true(text.contains(String(entry["author"])), "CREDITS.md never credits %s" % entry["author"]) assert_true(text.contains(String(entry["url"])), "CREDITS.md has no link for %s" % entry["name"]) func test_the_asset_document_covers_every_source_too() -> void: var f := FileAccess.open("res://docs/ASSETS.md", FileAccess.READ) assert_not_null(f) var text := f.get_as_text() f.close() for entry in Credits.SOURCES: assert_true(text.contains(String(entry["url"])), "docs/ASSETS.md has no entry for %s" % entry["name"]) ## Every pack in the repository's own asset directories must be accounted for. ## Committing art without recording where it came from is how a project ends up ## unable to say whether it may ship. func test_the_committed_ui_art_is_attributed() -> void: assert_true(DirAccess.dir_exists_absolute("res://assets/sprites/ui"), "the UI art should be committed") var names := "" for entry in Credits.SOURCES: names += String(entry["name"]) assert_true(names.contains("Complete UI Essential Pack"), "the UI pack has to be credited before its art is shipped")