Skip to content

Commit

Permalink
Fixing test again...
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-rueda committed Apr 5, 2022
1 parent 76696a4 commit 757ece8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions superset/cli/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def export_dashboards(dashboard_file: Optional[str] = None) -> None:
from superset.dashboards.commands.export import ExportDashboardsCommand
from superset.models.dashboard import Dashboard

# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username="admin")

dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
Expand Down Expand Up @@ -108,6 +109,7 @@ def export_datasources(datasource_file: Optional[str] = None) -> None:
from superset.connectors.sqla.models import SqlaTable
from superset.datasets.commands.export import ExportDatasetsCommand

# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username="admin")

dataset_ids = [id_ for (id_,) in db.session.query(SqlaTable.id).all()]
Expand Down Expand Up @@ -149,6 +151,7 @@ def import_dashboards(path: str, username: Optional[str]) -> None:
)

if username is not None:
# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username=username)
if is_zipfile(path):
with ZipFile(path) as bundle:
Expand Down Expand Up @@ -314,6 +317,7 @@ def import_dashboards(path: str, recursive: bool, username: str) -> None:
elif path_object.exists() and recursive:
files.extend(path_object.rglob("*.json"))
if username is not None:
# pylint: disable=assigning-non-slot
g.user = security_manager.find_user(username=username)
contents = {}
for path_ in files:
Expand Down
3 changes: 3 additions & 0 deletions superset/tasks/async_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@
def ensure_user_is_set(user_id: Optional[int]) -> None:
user_is_not_set = not (hasattr(g, "user") and g.user is not None)
if user_is_not_set and user_id is not None:
# pylint: disable=assigning-non-slot
g.user = security_manager.get_user_by_id(user_id)
elif user_is_not_set:
# pylint: disable=assigning-non-slot
g.user = security_manager.get_anonymous_user()


def set_form_data(form_data: Dict[str, Any]) -> None:
# pylint: disable=assigning-non-slot
g.form_data = form_data


Expand Down
2 changes: 1 addition & 1 deletion superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def apply(self, query: Query, value: Any) -> Query:
)


class CsvResponse(Response): # pylint: disable=too-many-ancestors
class CsvResponse(Response):
"""
Override Response to take into account csv encoding from config.py
"""
Expand Down
1 change: 1 addition & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,7 @@ def warm_up_cache( # pylint: disable=too-many-locals,no-self-use
force=True,
)

# pylint: disable=assigning-non-slot
g.form_data = form_data
payload = obj.get_payload()
delattr(g, "form_data")
Expand Down
16 changes: 13 additions & 3 deletions tests/integration_tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,28 @@
# specific language governing permissions and limitations
# under the License.
# isort:skip_file
import unittest
import uuid
from datetime import date, datetime, time, timedelta
from decimal import Decimal
import json
import os
import re
from typing import Any, Tuple, List, Optional

from superset.databases.commands.exceptions import DatabaseInvalidError
from unittest.mock import Mock, patch
from tests.integration_tests.fixtures.birth_names_dashboard import (
load_birth_names_dashboard_with_slices,
load_birth_names_data,
)

import numpy as np
import pandas as pd
import pytest
from flask import g
from flask import Flask, g
import marshmallow
from sqlalchemy.exc import ArgumentError

import tests.integration_tests.test_app
from superset import app, db, security_manager
from superset.exceptions import CertificateException, SupersetException
from superset.models.core import Database, Log
Expand Down Expand Up @@ -69,6 +75,10 @@
from superset.utils.hashing import md5_sha_from_str
from superset.views.utils import build_extra_filters, get_form_data
from tests.integration_tests.base_tests import SupersetTestCase
from tests.integration_tests.fixtures.world_bank_dashboard import (
load_world_bank_dashboard_with_slices,
load_world_bank_data,
)

from .fixtures.certificates import ssl_certificate

Expand Down

0 comments on commit 757ece8

Please sign in to comment.