Skip to content

Commit

Permalink
Revert interim test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Jun 24, 2024
1 parent acfba3d commit 9ddd43b
Show file tree
Hide file tree
Showing 57 changed files with 228 additions and 406 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ basepython = python3.10
ignore_basepython_conflict = true
commands =
superset db upgrade
superset load_test_users
superset init
superset load-test-users
# use -s to be able to use break pointers.
# no args or tests/* can be passed as an argument to run all tests
pytest -s {posargs}
Expand Down
1 change: 0 additions & 1 deletion scripts/permissions_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=consider-using-transaction
from collections import defaultdict

from superset import db, security_manager
Expand Down
2 changes: 1 addition & 1 deletion scripts/python_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export SUPERSET_TESTENV=true
echo "Superset config module: $SUPERSET_CONFIG"

superset db upgrade
superset load_test_users
superset init
superset load-test-users

echo "Running tests"

Expand Down
8 changes: 0 additions & 8 deletions superset/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ def load_test_users() -> None:
Syncs permissions for those users/roles
"""
print(Fore.GREEN + "Loading a set of users for unit tests")
load_test_users_run()


def load_test_users_run() -> None:
"""
Loads admin, alpha, and gamma user for testing purposes
Syncs permissions for those users/roles
"""
if app.config["TESTING"]:
sm = security_manager

Expand Down
2 changes: 1 addition & 1 deletion superset/commands/chart/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def import_chart(
if chart.id is None:
db.session.flush()

if user := get_user():
if (user := get_user()) and user not in chart.owners:
chart.owners.append(user)

return chart
Expand Down
7 changes: 3 additions & 4 deletions superset/commands/chart/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
from superset.daos.dashboard import DashboardDAO
from superset.exceptions import SupersetSecurityException
from superset.models.slice import Slice
from superset.utils.decorators import on_error, transaction
from superset.tags.models import ObjectType
from superset.utils.decorators import on_error, transaction

logger = logging.getLogger(__name__)

Expand All @@ -62,14 +62,13 @@ def run(self) -> Model:
assert self._model

# Update tags
tags = self._properties.pop("tags", None)
if tags is not None:
if (tags := self._properties.pop("tags", None)) is not None:
update_tags(ObjectType.chart, self._model.id, self._model.tags, tags)

if self._properties.get("query_context_generation") is None:
self._properties["last_saved_at"] = datetime.now()
self._properties["last_saved_by"] = g.user

return ChartDAO.update(self._model, self._properties)

def validate(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion superset/commands/dashboard/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def import_dashboard(
if dashboard.id is None:
db.session.flush()

if user := get_user():
if (user := get_user()) and user not in dashboard.owners:
dashboard.owners.append(user)

return dashboard
2 changes: 1 addition & 1 deletion superset/commands/dashboard/permalink/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from sqlalchemy.exc import SQLAlchemyError

from superset import db
from superset.commands.dashboard.permalink.base import BaseDashboardPermalinkCommand
from superset.commands.key_value.upsert import UpsertKeyValueCommand
from superset.daos.dashboard import DashboardDAO
Expand Down Expand Up @@ -78,6 +77,7 @@ def run(self) -> str:
codec=self.codec,
).run()
assert key.id # for type checks
return encode_permalink_key(key=key.id, salt=self.salt)

def validate(self) -> None:
pass
11 changes: 4 additions & 7 deletions superset/commands/dashboard/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,16 @@ def run(self) -> Model:
assert self._model

# Update tags
tags = self._properties.pop("tags", None)
if tags is not None:
update_tags(
ObjectType.dashboard, self._model.id, self._model.tags, tags
)
if (tags := self._properties.pop("tags", None)) is not None:
update_tags(ObjectType.dashboard, self._model.id, self._model.tags, tags)

dashboard = DashboardDAO.update(self._model, self._properties, commit=False)
dashboard = DashboardDAO.update(self._model, self._properties)
if self._properties.get("json_metadata"):
DashboardDAO.set_dash_metadata(
dashboard,
data=json.loads(self._properties.get("json_metadata", "{}")),
)

return dashboard

def validate(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion superset/commands/database/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)
from superset.commands.database.test_connection import TestConnectionDatabaseCommand
from superset.daos.database import DatabaseDAO
from superset.daos.exceptions import DAOCreateFailedError
from superset.databases.ssh_tunnel.models import SSHTunnel
from superset.exceptions import SupersetErrorsException
from superset.extensions import event_logger, security_manager
from superset.models.core import Database
Expand Down
194 changes: 0 additions & 194 deletions superset/commands/database/csv_import.py

This file was deleted.

Loading

0 comments on commit 9ddd43b

Please sign in to comment.