Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,12 @@ list of tags from the following set:
This project is dedicated to the public domain. Copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](http://creativecommons.org/publicdomain/zero/1.0/).

All contributions to this project must be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of your copyright interest.

## Local Testing

Install circleci locally according to the [docs](https://circleci.com/docs/2.0/local-cli/).

brew install circleci
circleci config validate
pip install rtyaml
circleci local execute --job build
22 changes: 17 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import sys
import rtyaml

acceptable_allegation_length = 750
acceptable_text_length = 800
acceptable_text_length_ratio_above = .86

has_error = False
def error(*args):
global has_error
Expand Down Expand Up @@ -119,13 +123,21 @@ def remove_markdown_link_urls(s):
if bad_tags:
error(incident, cons, "Consequence has invalid 'tags': {}.".format(bad_tags))

stripped_text_length = len(remove_markdown_link_urls(incident["text"]))
stripped_cons_length = len(" ".join(remove_markdown_link_urls(str(cons)) for cons in incident["consequences"]))

# Suggest incidents whose allegation or text fields probably could be shortened.
if len(incident["allegation"]) > 750:
if len(incident["allegation"]) > acceptable_allegation_length:
error(incident, "'allegation' could probably be shorter.")
if len(incident["consequences"]) > 2 and len(remove_markdown_link_urls(incident["text"])) > 800:
error(incident, "'text' could probably be shorter.")
elif len(incident["consequences"]) > 2 and len(incident["text"]) > 400 and len(remove_markdown_link_urls(incident["text"])) > .8 * (len(incident["allegation"]) + len(" ".join(remove_markdown_link_urls(str(cons)) for cons in incident["consequences"]))):
error(incident, "'text' could probably be shorter.")

if len(incident["consequences"]) > 2:
if stripped_text_length > acceptable_text_length:
error(incident, "'text' is too long. Goal %d, found %d." % acceptable_text_length , stripped_text_length)

else:

if len(incident["text"]) > acceptable_text_length/2 and (stripped_text_length > (acceptable_text_length_ratio_above * (len(incident["allegation"]) + stripped_cons_length))):
error(incident, "'text' could should be shorter based on length of allegations and consequences. Goal %d, found %d." % ((acceptable_text_length_ratio_above * (len(incident["allegation"]) + stripped_cons_length)), stripped_text_length ))


if has_error:
Expand Down