Skip to content

Commit

Permalink
BUG: make busco tests altair version invariant (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sann5 authored Oct 17, 2023
1 parent 0b0c3af commit 89ca6e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 2 additions & 3 deletions q2_moshpit/busco/tests/data/plot_as_dict.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.15.1.json",
"config": {
"axis": {
"labelFontSize": 17,
Expand Down Expand Up @@ -603,7 +602,7 @@
"transform": [
{
"as": "x",
"calculate": "datum[param_2]"
"calculate": "datum[param_i]"
}
],
"width": 600
Expand All @@ -622,7 +621,7 @@
"number_of_scaffolds"
]
},
"name": "param_2",
"name": "param_i",
"value": "scaffold_n50"
}
],
Expand Down
16 changes: 15 additions & 1 deletion q2_moshpit/busco/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import tempfile
import zipfile
import json
import pandas as pd
from q2_moshpit.busco.utils import (
_parse_busco_params,
Expand Down Expand Up @@ -158,13 +159,26 @@ def test_draw_busco_plots_for_render(self):
labelFontSize=17,
)

# Replace param value to make the dict altair version invariant
observed = observed.replace("param_1", "param_i")
observed = observed.replace("param_2", "param_i")

# Json string to dict
observed = json.loads(observed)

# Remove $schema k-v pair (also altair version variant)
observed.pop("$schema")

# Load expected data
p = self.get_data_path("plot_as_dict.json")
with open(p, "r") as json_file:
expected = json_file.read()

# Json string to dictionary
expected = json.loads(expected)

self.maxDiff = None
self.assertEqual(expected, observed)
self.assertDictEqual(expected, observed)

# Test `_draw_busco_plots`
def mock_draw_busco_plots(self, tmp_path: str, num_files: int) -> dict:
Expand Down

0 comments on commit 89ca6e2

Please sign in to comment.