chore: move dashboard screenshot standalone logic (#23003)

This commit is contained in:
Elizabeth Thompson
2023-02-15 14:35:08 -08:00
committed by GitHub
parent f6c304437a
commit 4ddf67fc14
12 changed files with 76 additions and 56 deletions

View File

@@ -27,7 +27,9 @@ import yaml
from freezegun import freeze_time
import superset.cli.importexport
from superset import app
import superset.cli.thumbnails
from superset import app, db
from superset.models.dashboard import Dashboard
from tests.integration_tests.fixtures.birth_names_dashboard import (
load_birth_names_dashboard_with_slices,
load_birth_names_data,
@@ -495,3 +497,23 @@ def test_failing_import_datasets_versioned_export(
)
assert_cli_fails_properly(response, caplog)
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
@mock.patch("superset.tasks.thumbnails.cache_dashboard_thumbnail")
def test_compute_thumbnails(thumbnail_mock, app_context, fs):
thumbnail_mock.return_value = None
runner = app.test_cli_runner()
dashboard = db.session.query(Dashboard).filter_by(slug="births").first()
response = runner.invoke(
superset.cli.thumbnails.compute_thumbnails,
["-d", "-i", dashboard.id],
)
thumbnail_mock.assert_called_with(
None,
dashboard.id,
force=False,
)
assert response.exit_code == 0

View File

@@ -663,11 +663,9 @@ def test_email_chart_report_schedule(
)
# assert that the link sent is correct
assert (
'<a href="http://0.0.0.0:8080/explore/?'
"form_data=%7B%22slice_id%22%3A%20"
f"{create_report_email_chart.chart.id}%7D&"
'standalone=0&force=false">Explore in Superset</a>'
in email_mock.call_args[0][2]
'<a href="http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+'
f"{create_report_email_chart.chart.id}"
'%7D&force=false">Explore in Superset</a>' in email_mock.call_args[0][2]
)
# Assert the email smtp address
assert email_mock.call_args[0][0] == notification_targets[0]
@@ -720,11 +718,9 @@ def test_email_chart_report_schedule_alpha_owner(
# assert that the link sent is correct
assert (
'<a href="http://0.0.0.0:8080/explore/?'
"form_data=%7B%22slice_id%22%3A%20"
f"{create_report_email_chart_alpha_owner.chart.id}%7D&"
'standalone=0&force=false">Explore in Superset</a>'
in email_mock.call_args[0][2]
'<a href="http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+'
f"{create_report_email_chart_alpha_owner.chart.id}"
'%7D&force=false">Explore in Superset</a>' in email_mock.call_args[0][2]
)
# Assert the email smtp address
assert email_mock.call_args[0][0] == notification_targets[0]
@@ -767,11 +763,9 @@ def test_email_chart_report_schedule_force_screenshot(
)
# assert that the link sent is correct
assert (
'<a href="http://0.0.0.0:8080/explore/?'
"form_data=%7B%22slice_id%22%3A%20"
f"{create_report_email_chart_force_screenshot.chart.id}%7D&"
'standalone=0&force=true">Explore in Superset</a>'
in email_mock.call_args[0][2]
'<a href="http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+'
f"{create_report_email_chart_force_screenshot.chart.id}"
'%7D&force=true">Explore in Superset</a>' in email_mock.call_args[0][2]
)
# Assert the email smtp address
assert email_mock.call_args[0][0] == notification_targets[0]
@@ -806,11 +800,9 @@ def test_email_chart_alert_schedule(
notification_targets = get_target_from_report_schedule(create_alert_email_chart)
# assert that the link sent is correct
assert (
'<a href="http://0.0.0.0:8080/explore/?'
"form_data=%7B%22slice_id%22%3A%20"
f"{create_alert_email_chart.chart.id}%7D&"
'standalone=0&force=true">Explore in Superset</a>'
in email_mock.call_args[0][2]
'<a href="http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+'
f"{create_alert_email_chart.chart.id}"
'%7D&force=true">Explore in Superset</a>' in email_mock.call_args[0][2]
)
# Assert the email smtp address
assert email_mock.call_args[0][0] == notification_targets[0]
@@ -880,11 +872,9 @@ def test_email_chart_report_schedule_with_csv(
)
# assert that the link sent is correct
assert (
'<a href="http://0.0.0.0:8080/explore/?'
"form_data=%7B%22slice_id%22%3A%20"
'<a href="http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+'
f"{create_report_email_chart_with_csv.chart.id}%7D&"
'standalone=0&force=false">Explore in Superset</a>'
in email_mock.call_args[0][2]
'force=false">Explore in Superset</a>' in email_mock.call_args[0][2]
)
# Assert the email smtp address
assert email_mock.call_args[0][0] == notification_targets[0]
@@ -1313,7 +1303,7 @@ def test_slack_chart_report_schedule_with_text(
| 1 | c21 | c22 | c23 |"""
assert table_markdown in post_message_mock.call_args[1]["text"]
assert (
f"<http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A%20{create_report_slack_chart_with_text.chart.id}%7D&standalone=0&force=false|Explore in Superset>"
f"<http://0.0.0.0:8080/explore/?form_data=%7B%22slice_id%22%3A+{create_report_slack_chart_with_text.chart.id}%7D&force=false|Explore in Superset>"
in post_message_mock.call_args[1]["text"]
)