Skip to content

Commit

Permalink
Save some lines in test files by excluding all generated_by by default
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed Nov 9, 2024
1 parent 11587e5 commit bd8d892
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion scripts/diff_jsons.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
parser.add_argument("first_json", help="first JSON to compare")
parser.add_argument("second_json", help="second JSON to compare")
parser.add_argument("--significant-digits", type=int, default=5, help="number of significant digits to use when comparing numeric values")
parser.add_argument("--exclude-paths", nargs="+", action=ExtendOverwriteDefault, help="list of paths to exclude from consideration when performing a diff", default=["root['generated_by']['version']", "root['meta']['updated']"])
parser.add_argument("--exclude-paths", nargs="+", action=ExtendOverwriteDefault, help="list of paths to exclude from consideration when performing a diff", default=["root['generated_by']", "root['meta']['updated']"])
parser.add_argument("--exclude-regex-paths", nargs="+", action="extend", help="list of path regular expressions to exclude from consideration when performing a diff")
parser.add_argument("--ignore-numeric-type-changes", action="store_true", help="ignore numeric type changes in the diff (e.g., int of 1 to float of 1.0)")

Expand Down
6 changes: 2 additions & 4 deletions tests/functional/ancestral/cram/case-sensitive.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Change the _reference_ to lowercase

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" \
> "$TESTDIR/../data/simple-genome/nt_muts.ref-seq.json" \
> "nt_muts.ref-seq.json" \
> --exclude-paths "root['generated_by']"
> "nt_muts.ref-seq.json"
{}


Expand All @@ -37,6 +36,5 @@ be lowecase which will be compared against the uppercase reference

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" \
> "$TESTDIR/../data/simple-genome/nt_muts.ref-seq.json" \
> "nt_muts.ref-seq.json" \
> --exclude-paths "root['generated_by']"
> "nt_muts.ref-seq.json"
{}
6 changes: 2 additions & 4 deletions tests/functional/ancestral/cram/general.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ node-data JSON we diff against.

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" \
> "$TESTDIR/../data/simple-genome/nt_muts.ref-seq.json" \
> "nt_muts.ref-seq.json" \
> --exclude-paths "root['generated_by']"
> "nt_muts.ref-seq.json"
{}

Same as above but without providing a `--root-sequence`. The effect of this on behaviour is:
Expand All @@ -39,6 +38,5 @@ mutations (as there's nothing to compare the root node to)

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" \
> "$TESTDIR/../data/simple-genome/nt_muts.no-ref-seq.json" \
> "nt_muts.no-ref-seq.json" \
> --exclude-paths "root['generated_by']"
> "nt_muts.no-ref-seq.json"
{}
3 changes: 1 addition & 2 deletions tests/functional/clades/cram/membership-and-label.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ Test custom membership key + label key. The only change should be the key names

$ cat clades_custom.json | sed "s/lineage/clade_membership/" | sed "s/origin/clade/" > clades_sed.json

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_sed.json \
> --exclude-paths "root['generated_by']"
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_sed.json
{}
3 changes: 1 addition & 2 deletions tests/functional/clades/cram/no-label.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ Test the ability to _not_ export a branch label (same logic as not exporting the
> --label-name none \
> --output-node-data clades_no-labels.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_no-labels.json \
> --exclude-paths "root['generated_by']"
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/clades.json" clades_no-labels.json
{'dictionary_item_removed': [root['branches']]}
9 changes: 3 additions & 6 deletions tests/functional/clades/cram/root-clade-identification.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ This is an oversight and ideally would be fixed
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_1.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_1.json" toy_clades_1.json \
> --exclude-paths "root['generated_by']"
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_1.json" toy_clades_1.json
{}

A clade which exists at the root is identified (and correctly propogated) if the root sequence
Expand All @@ -25,8 +24,7 @@ is explicitly set.
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_2a.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2a.json \
> --exclude-paths "root['generated_by']"
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2a.json
{}

A clade which exists at the root is identified (and correctly propogated) without a root sequence
Expand All @@ -38,6 +36,5 @@ if the (branch leading to the) root has the clade-defining mutation.
> --clades "$TESTDIR/../data/toy_clades_nuc.tsv" \
> --output-node-data toy_clades_2b.json &>/dev/null

$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2b.json \
> --exclude-paths "root['generated_by']"
$ python3 "$TESTDIR/../../../../scripts/diff_jsons.py" "$TESTDIR/../data/toy_clades_2.json" toy_clades_2b.json
{}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Confirm that trees match expected topology and branch lengths, given that the ou
> "$TESTDIR/../data/mutations_per_site_branch_lengths.json" \
> branch_lengths.json \
> --significant-digits 0 \
> --exclude-paths "root['generated_by']['version']" "root['input_tree']"
> --exclude-paths "generated_by" "input_tree"
{}
2 changes: 1 addition & 1 deletion tests/functional/refine/cram/not-timetree-mutations.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Confirm that trees match expected topology and branch lengths, given that the ou
> "$TESTDIR/../data/integer_branch_lengths.json" \
> branch_lengths.json \
> --significant-digits 0 \
> --exclude-paths "root['generated_by']['version']" "root['input_tree']" "root['alignment']"
> --exclude-paths "generated_by" "input_tree" "alignment"
{}

0 comments on commit bd8d892

Please sign in to comment.