test: fix flaky Python unit tests (#12253)

This commit is contained in:
Karol Kostrzewa
2021-01-06 01:40:01 +01:00
committed by GitHub
parent 1b908ab9f1
commit 1a2680d4a1
6 changed files with 24 additions and 2 deletions

View File

@@ -19,6 +19,7 @@
"""Unit tests for Superset"""
import json
from io import BytesIO
from unittest import mock
from zipfile import is_zipfile, ZipFile
import prison
@@ -343,6 +344,10 @@ class TestDatabaseApi(SupersetTestCase):
"Invalid connection string", response["message"]["sqlalchemy_uri"][0],
)
@mock.patch(
"superset.views.core.app.config",
{**app.config, "PREVENT_UNSAFE_DB_CONNECTIONS": True},
)
def test_create_database_fail_sqllite(self):
"""
Database API: Test create fail with sqllite
@@ -493,6 +498,9 @@ class TestDatabaseApi(SupersetTestCase):
"Invalid connection string", response["message"]["sqlalchemy_uri"][0],
)
db.session.delete(test_database)
db.session.commit()
def test_delete_database(self):
"""
Database API: Test delete
@@ -830,6 +838,8 @@ class TestDatabaseApi(SupersetTestCase):
}
self.assertEqual(response, expected_response)
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = False
@pytest.mark.usefixtures(
"load_unicode_dashboard_with_position", "load_energy_table_with_slice"
)