import os
import yaml
import re
-import pprint
test_dir = "."
yaml_name = "../adventure.yaml"
obj["descriptions"][j] = True
objects[i] = (obj_name, obj)
-
def hint_coverage(hints, text):
for name, hint in hints:
if hint["question"] != True:
if hint["hint"] != True:
if search(hint["hint"], text):
hint["hint"] = True
- continue
+
+def special_coverage(specials, text):
+ for name, special in specials:
+ if special["message"] == None:
+ special["message"] = True
+ if special["message"] != True:
+ if search(special["message"], text):
+ special["message"] = True
def threshold_coverage(classes, text):
for i, msg in enumerate(classes):
hintsraw = db["hints"]
classes = db["classes"]
turn_thresholds = db["turn_thresholds"]
+ specials = db["specials"]
hints = []
for hint in hintsraw:
hint_coverage(hints, text)
threshold_coverage(classes, text)
threshold_coverage(turn_thresholds, text)
+ special_coverage(specials, text)
location_html = ""
location_total = len(locations) * 2
turn_html += arb_msg_row.format(msg["threshold"], success)
turn_percent = round((turn_covered / float(turn_total)) * 100, 1)
+ special_html = ""
+ special_total = len(specials)
+ special_covered = 0
+ for name, special in specials:
+ if special["message"] != True:
+ success = "uncovered"
+ else:
+ success = "covered"
+ special_covered += 1
+ special_html += arb_msg_row.format(name, success)
+ special_percent = round((special_covered / float(special_total)) * 100, 1)
+
# output some quick report stats
print("\nadventure.yaml coverage rate:")
print(" locations..........: {}% covered ({} of {})".format(location_percent, location_covered, location_total))
print(" hints..............: {}% covered ({} of {})".format(hints_percent, hints_covered, hints_total))
print(" classes............: {}% covered ({} of {})".format(class_percent, class_covered, class_total))
print(" turn_thresholds....: {}% covered ({} of {})".format(turn_percent, turn_covered, turn_total))
+ print(" specials...........: {}% covered ({} of {})".format(special_percent, special_covered, special_total))
# render HTML report
with open(html_output_path, "w") as f:
hints_total, hints_covered, hints_percent,
class_total, class_covered, class_percent,
turn_total, turn_covered, turn_percent,
- location_html, arb_msg_html, object_html, hints_html, class_html, turn_html
+ special_total, special_covered, special_percent,
+ location_html, arb_msg_html, object_html, hints_html,
+ class_html, turn_html, special_html
))