Skip to content

Commit

Permalink
fix patch PREVENT_UNSAFE_DB_CONNECTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
kstrz committed Jan 5, 2021
1 parent 1640f9f commit e8a432c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/databases/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -343,11 +344,14 @@ def test_create_database_uri_validate(self):
"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
"""
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = True
database_data = {
"database_name": "test-create-sqlite-database",
"sqlalchemy_uri": "sqlite:////some.db",
Expand All @@ -367,7 +371,6 @@ def test_create_database_fail_sqllite(self):
}
self.assertEqual(response_data, expected_response)
self.assertEqual(response.status_code, 400)
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = False

def test_create_database_conn_fail(self):
"""
Expand Down

0 comments on commit e8a432c

Please sign in to comment.