mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
7620: Start removing dependencies on requests (#7643)
* 7620: Start removing dependencies on requests * Patch urllib.request.urlopen instead of requests.get * Try to fix flake8 * More work on flake8 import errors * First attempt at using urllib with cookies * Fix pylint/flake8 * Fix test_deliver_slice_csv_attachment * Fix test_deliver_slice_csv_inline * Import requests and pydruid conditionally, remove dependency on prison * Fix flake errors * Fix load_examples * Please flake * Skip tests depending on optional deps * Try to please flake * Address review comments * Remove Druid-related UI * Revert "Remove Druid-related UI" This reverts commit d7e0f166cc3f3dd2496b4a666e177f0c191aeb0f. * Skip a few tests more * Put imports in right order * Apply black patch * Please flake * Please black, silence flake * Use flake8 silencing the right way * Add deps for CI
This commit is contained in:
committed by
Maxime Beauchemin
parent
cbac428b28
commit
e23920b8ba
@@ -14,6 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# flake8: noqa I202
|
||||
"""Unit tests for Superset"""
|
||||
from datetime import datetime
|
||||
import json
|
||||
@@ -21,12 +22,16 @@ import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from superset import db, security_manager
|
||||
from superset.connectors.druid.models import (
|
||||
DruidCluster,
|
||||
DruidColumn,
|
||||
DruidDatasource,
|
||||
DruidMetric,
|
||||
)
|
||||
|
||||
try:
|
||||
from superset.connectors.druid.models import (
|
||||
DruidCluster,
|
||||
DruidColumn,
|
||||
DruidDatasource,
|
||||
DruidMetric,
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
from .base_tests import SupersetTestCase
|
||||
|
||||
|
||||
@@ -131,6 +136,9 @@ class DruidTests(SupersetTestCase):
|
||||
|
||||
return cluster
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_client(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -189,6 +197,9 @@ class DruidTests(SupersetTestCase):
|
||||
resp = self.get_json_resp(url, {"form_data": json.dumps(form_data)})
|
||||
self.assertEqual("Canada", resp["data"]["records"][0]["dim1"])
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
def test_druid_sync_from_config(self):
|
||||
CLUSTER_NAME = "new_druid"
|
||||
self.login()
|
||||
@@ -276,6 +287,9 @@ class DruidTests(SupersetTestCase):
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
def test_filter_druid_datasource(self):
|
||||
CLUSTER_NAME = "new_druid"
|
||||
cluster = self.get_or_create(
|
||||
@@ -311,6 +325,9 @@ class DruidTests(SupersetTestCase):
|
||||
self.assertIn("datasource_for_gamma", resp)
|
||||
self.assertNotIn("datasource_not_for_gamma", resp)
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_sync_druid_perm(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -354,6 +371,9 @@ class DruidTests(SupersetTestCase):
|
||||
)
|
||||
assert pv is not None
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_refresh_metadata(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -381,6 +401,9 @@ class DruidTests(SupersetTestCase):
|
||||
json.loads(metric.json)["type"], "double{}".format(agg.capitalize())
|
||||
)
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_refresh_metadata_augment_type(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -413,6 +436,9 @@ class DruidTests(SupersetTestCase):
|
||||
|
||||
self.assertEqual(metric.json_obj["type"], "long{}".format(agg.capitalize()))
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_refresh_metadata_augment_verbose_name(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -444,6 +470,9 @@ class DruidTests(SupersetTestCase):
|
||||
for metric in metrics:
|
||||
self.assertEqual(metric.verbose_name, metric.metric_name)
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
def test_urls(self):
|
||||
cluster = self.get_test_cluster_obj()
|
||||
self.assertEquals(
|
||||
@@ -460,6 +489,9 @@ class DruidTests(SupersetTestCase):
|
||||
cluster.get_base_broker_url(), "http://localhost:7980/druid/v2"
|
||||
)
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_druid_time_granularities(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
@@ -518,6 +550,9 @@ class DruidTests(SupersetTestCase):
|
||||
instance.timeseries.call_args[1]["granularity"]["period"],
|
||||
)
|
||||
|
||||
@unittest.skipUnless(
|
||||
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
|
||||
)
|
||||
@patch("superset.connectors.druid.models.PyDruid")
|
||||
def test_external_metadata(self, PyDruid):
|
||||
self.login(username="admin")
|
||||
|
||||
Reference in New Issue
Block a user