Skip to content

Commit

Permalink
fix tests and remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Feb 14, 2023
1 parent a6e561c commit 4a375e7
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions tests/integration_tests/charts/commands_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,52 +88,7 @@ def test_export_chart_command(self, mock_g):
"dataset_uuid": str(example_chart.table.uuid),
"uuid": str(example_chart.uuid),
"version": "1.0.0",
}

@patch("superset.security.manager.g")
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_export_chart_with_query_context(self, mock_g):
"""Test that charts that have a query_context are exported correctly"""

mock_g.user = security_manager.find_user("alpha")
example_chart = db.session.query(Slice).filter_by(slice_name="Heatmap").one()
command = ExportChartsCommand([example_chart.id])

contents = dict(command.run())

expected = [
"metadata.yaml",
f"charts/Heatmap_{example_chart.id}.yaml",
"datasets/examples/energy_usage.yaml",
"databases/examples.yaml",
]
assert expected == list(contents.keys())

metadata = yaml.safe_load(contents[f"charts/Heatmap_{example_chart.id}.yaml"])

assert metadata == {
"slice_name": "Heatmap",
"description": None,
"certified_by": None,
"certification_details": None,
"viz_type": "heatmap",
"params": {
"all_columns_x": "source",
"all_columns_y": "target",
"canvas_image_rendering": "pixelated",
"collapsed_fieldsets": "",
"linear_color_scheme": "blue_white_yellow",
"metric": "sum__value",
"normalize_across": "heatmap",
"slice_name": "Heatmap",
"viz_type": "heatmap",
"xscale_interval": "1",
"yscale_interval": "1",
},
"cache_timeout": None,
"dataset_uuid": str(example_chart.table.uuid),
"uuid": str(example_chart.uuid),
"version": "1.0.0",
"query_context": None,
}

@patch("superset.security.manager.g")
Expand Down Expand Up @@ -179,6 +134,7 @@ def test_export_chart_command_key_order(self, mock_g):
"certification_details",
"viz_type",
"params",
"query_context",
"cache_timeout",
"uuid",
"version",
Expand Down

0 comments on commit 4a375e7

Please sign in to comment.