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

BUG: test_draw_busco_plots_for_render is altair version variant #83

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
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