diff --git a/Getting-Started.md b/Getting-Started.md index 83082642..3fc0d88f 100644 --- a/Getting-Started.md +++ b/Getting-Started.md @@ -39,15 +39,32 @@ Step 3: Ensuring your RWS meets the technical requirements Step 4: Testing your RWS locally -------------------------------- -Once you've made your changes to your local branch, you can open a terminal and run the command `python3 check_sites.py`. Currently, this will produce a number of check failures due to older submissions in the set failing recent changes to checks. If no members of your set are mentioned in the list of failed checks, then your submission should be fine. If you would like a cleaner way of looking for problems in your set, follow these steps: +Once you've made your changes to your local branch, you can open a terminal and run the command -1. Run `cp related_website_sets.JSON my_rws.JSON` in your shell +`python3 check_sites.py --primaries=https://yourprimary.example` -2. Make your changes to `my_rws.JSON` and make sure `related_website_sets.JSON` is identical to the version in main. +or, equivalently, run -3. To test your local changes, run `python3 check_sites.py -i my_rws.JSON --with_diff`. When this command finishes running, you will either see "success" (meaning your submission passed all of the checks) or you will see a list of failed checks. +`python3 check_sites.py -p https://yourprimary.example` -4. When you are ready to submit, copy your changes from `my_rws.JSON` into `related_website_sets.JSON` and delete `my_rws.JSON` +You will get the results of any failed tests in the terminal. Otherwise, you will see "success" if your changes are passing all of the checks. Make sure that the text of the primary site you're passing into the command line is identical to the primary site you have listed in the related_website_sets.JSON file, or the tests will fail. If you would like to test multiple Related Website Sets at once, you can run the command above with multiple primaries in a comma separated list. + +For example, to get the results of the checks for a set with `https://foo.example` as its primary, you would run + +`python3 check_sites.py --primaries=https://foo.example` + +or equivalently + +`python3 check_sites.py -p https://foo.example` + + +To get the results for both the set with `https://foo.example` as its primary, and for the set with `https://bar.example` as its primary, you would run + +`python3 check_sites.py --primaries=https://foo.example,https://bar.example` + +or + +`python3 check_sites.py -p https://foo.example -p https://bar.example` Step 5: Submitting your RWS --------------------------- diff --git a/check_sites.py b/check_sites.py index 3f87405b..665fcebe 100644 --- a/check_sites.py +++ b/check_sites.py @@ -47,9 +47,11 @@ def find_diff_sets(old_sets, new_sets): def main(): args = sys.argv[1:] input_file = 'related_website_sets.JSON' + cli_primaries = [] input_prefix = '' with_diff = False - opts, _ = getopt.getopt(args, "i:", ["data_directory=", "with_diff"]) + opts, _ = getopt.getopt(args, "i:p:", ["data_directory=", "with_diff", + "primaries="]) for opt, arg in opts: if opt == '-i': input_file = arg @@ -57,6 +59,8 @@ def main(): input_prefix = arg if opt == '--with_diff': with_diff = True + if opt == '--primaries' or opt == '-p': + cli_primaries.extend(arg.split(',')) # Open and load the json of the new list with open(input_file) as f: @@ -111,10 +115,14 @@ def main(): return old_checker = RwsCheck(old_sites, etlds, icanns) check_sets, subtracted_sets = find_diff_sets(old_checker.load_sets(), rws_checker.load_sets()) - # TODO: add variable and check for subtracted_sets in case of user - # removing old set from the list else: check_sets = rws_checker.load_sets() + if cli_primaries: + absent_primaries = [p for p in cli_primaries if p not in check_sets] + for p in absent_primaries: + error_texts.append("There was an error loading the set:\n" + + f"could not find set with primary site \"{p}\"") + check_sets = {p: check_sets[p] for p in cli_primaries if p in check_sets} # Run check on subtracted sets rws_checker.find_invalid_removal(subtracted_sets)