mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[flake8] Resolve E1?? errors (#3805)
This commit is contained in:
committed by
Maxime Beauchemin
parent
35810ce2bf
commit
690de862e8
@@ -547,11 +547,11 @@ class RequestAccessTests(SupersetTestCase):
|
||||
'/superset/update_role/',
|
||||
data=json.dumps({
|
||||
'users': [{
|
||||
'username': 'gamma',
|
||||
'first_name': 'Gamma',
|
||||
'last_name': 'Gamma',
|
||||
'email': 'gamma@superset.com',
|
||||
}],
|
||||
'username': 'gamma',
|
||||
'first_name': 'Gamma',
|
||||
'last_name': 'Gamma',
|
||||
'email': 'gamma@superset.com',
|
||||
}],
|
||||
'role_name': update_role_str,
|
||||
}),
|
||||
follow_redirects=True,
|
||||
|
||||
@@ -28,9 +28,9 @@ class SupersetTestCase(unittest.TestCase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if (
|
||||
self.requires_examples and
|
||||
not os.environ.get('SOLO_TEST') and
|
||||
not os.environ.get('examples_loaded')
|
||||
self.requires_examples and
|
||||
not os.environ.get('SOLO_TEST') and
|
||||
not os.environ.get('examples_loaded')
|
||||
):
|
||||
logging.info("Loading examples")
|
||||
cli.load_examples(load_test_data=True)
|
||||
@@ -133,8 +133,8 @@ class SupersetTestCase(unittest.TestCase):
|
||||
def get_slice(self, slice_name, session):
|
||||
slc = (
|
||||
session.query(models.Slice)
|
||||
.filter_by(slice_name=slice_name)
|
||||
.one()
|
||||
.filter_by(slice_name=slice_name)
|
||||
.one()
|
||||
)
|
||||
session.expunge_all()
|
||||
return slc
|
||||
@@ -169,20 +169,20 @@ class SupersetTestCase(unittest.TestCase):
|
||||
def get_main_database(self, session):
|
||||
return (
|
||||
db.session.query(models.Database)
|
||||
.filter_by(database_name='main')
|
||||
.first()
|
||||
.filter_by(database_name='main')
|
||||
.first()
|
||||
)
|
||||
|
||||
def get_access_requests(self, username, ds_type, ds_id):
|
||||
DAR = models.DatasourceAccessRequest
|
||||
return (
|
||||
db.session.query(DAR)
|
||||
.filter(
|
||||
.filter(
|
||||
DAR.created_by == sm.find_user(username=username),
|
||||
DAR.datasource_type == ds_type,
|
||||
DAR.datasource_id == ds_id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
.first()
|
||||
)
|
||||
|
||||
def logout(self):
|
||||
|
||||
@@ -365,7 +365,8 @@ class CoreTests(SupersetTestCase):
|
||||
|
||||
resp = self.client.get('/kv/{}/'.format(kv.id))
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertEqual(json.loads(value),
|
||||
self.assertEqual(
|
||||
json.loads(value),
|
||||
json.loads(resp.data.decode('utf-8')))
|
||||
|
||||
try:
|
||||
@@ -436,8 +437,8 @@ class CoreTests(SupersetTestCase):
|
||||
self.login(username=username)
|
||||
dash = (
|
||||
db.session.query(models.Dashboard)
|
||||
.filter_by(slug="births")
|
||||
.first()
|
||||
.filter_by(slug="births")
|
||||
.first()
|
||||
)
|
||||
origin_title = dash.dashboard_title
|
||||
positions = []
|
||||
@@ -459,8 +460,8 @@ class CoreTests(SupersetTestCase):
|
||||
self.get_resp(url, data=dict(data=json.dumps(data)))
|
||||
updatedDash = (
|
||||
db.session.query(models.Dashboard)
|
||||
.filter_by(slug="births")
|
||||
.first()
|
||||
.filter_by(slug="births")
|
||||
.first()
|
||||
)
|
||||
self.assertEqual(updatedDash.dashboard_title, 'new title')
|
||||
# # bring back dashboard original title
|
||||
|
||||
@@ -21,49 +21,49 @@ class PickableMock(Mock):
|
||||
return (Mock, ())
|
||||
|
||||
SEGMENT_METADATA = [{
|
||||
"id": "some_id",
|
||||
"intervals": ["2013-05-13T00:00:00.000Z/2013-05-14T00:00:00.000Z"],
|
||||
"columns": {
|
||||
"__time": {
|
||||
"type": "LONG", "hasMultipleValues": False,
|
||||
"size": 407240380, "cardinality": None, "errorMessage": None},
|
||||
"dim1": {
|
||||
"type": "STRING", "hasMultipleValues": False,
|
||||
"size": 100000, "cardinality": 1944, "errorMessage": None},
|
||||
"dim2": {
|
||||
"type": "STRING", "hasMultipleValues": True,
|
||||
"size": 100000, "cardinality": 1504, "errorMessage": None},
|
||||
"metric1": {
|
||||
"type": "FLOAT", "hasMultipleValues": False,
|
||||
"size": 100000, "cardinality": None, "errorMessage": None},
|
||||
},
|
||||
"aggregators": {
|
||||
"metric1": {
|
||||
"type": "longSum",
|
||||
"name": "metric1",
|
||||
"fieldName": "metric1"},
|
||||
},
|
||||
"size": 300000,
|
||||
"numRows": 5000000,
|
||||
"id": "some_id",
|
||||
"intervals": ["2013-05-13T00:00:00.000Z/2013-05-14T00:00:00.000Z"],
|
||||
"columns": {
|
||||
"__time": {
|
||||
"type": "LONG", "hasMultipleValues": False,
|
||||
"size": 407240380, "cardinality": None, "errorMessage": None},
|
||||
"dim1": {
|
||||
"type": "STRING", "hasMultipleValues": False,
|
||||
"size": 100000, "cardinality": 1944, "errorMessage": None},
|
||||
"dim2": {
|
||||
"type": "STRING", "hasMultipleValues": True,
|
||||
"size": 100000, "cardinality": 1504, "errorMessage": None},
|
||||
"metric1": {
|
||||
"type": "FLOAT", "hasMultipleValues": False,
|
||||
"size": 100000, "cardinality": None, "errorMessage": None},
|
||||
},
|
||||
"aggregators": {
|
||||
"metric1": {
|
||||
"type": "longSum",
|
||||
"name": "metric1",
|
||||
"fieldName": "metric1"},
|
||||
},
|
||||
"size": 300000,
|
||||
"numRows": 5000000,
|
||||
}]
|
||||
|
||||
GB_RESULT_SET = [
|
||||
{
|
||||
"version": "v1",
|
||||
"timestamp": "2012-01-01T00:00:00.000Z",
|
||||
"event": {
|
||||
"dim1": 'Canada',
|
||||
"metric1": 12345678,
|
||||
{
|
||||
"version": "v1",
|
||||
"timestamp": "2012-01-01T00:00:00.000Z",
|
||||
"event": {
|
||||
"dim1": 'Canada',
|
||||
"metric1": 12345678,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"version": "v1",
|
||||
"timestamp": "2012-01-01T00:00:00.000Z",
|
||||
"event": {
|
||||
"dim1": 'USA',
|
||||
"metric1": 12345678 / 2,
|
||||
{
|
||||
"version": "v1",
|
||||
"timestamp": "2012-01-01T00:00:00.000Z",
|
||||
"event": {
|
||||
"dim1": 'USA',
|
||||
"metric1": 12345678 / 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -337,26 +337,30 @@ class DruidTests(SupersetTestCase):
|
||||
metric_name='unused_count',
|
||||
verbose_name='COUNT(*)',
|
||||
metric_type='count',
|
||||
json=json.dumps({'type': 'count', 'name': 'unused_count'})),
|
||||
json=json.dumps({'type': 'count', 'name': 'unused_count'}),
|
||||
),
|
||||
'some_sum': DruidMetric(
|
||||
metric_name='some_sum',
|
||||
verbose_name='SUM(*)',
|
||||
metric_type='sum',
|
||||
json=json.dumps({'type': 'sum', 'name': 'sum'})),
|
||||
json=json.dumps({'type': 'sum', 'name': 'sum'}),
|
||||
),
|
||||
'a_histogram': DruidMetric(
|
||||
metric_name='a_histogram',
|
||||
verbose_name='APPROXIMATE_HISTOGRAM(*)',
|
||||
metric_type='approxHistogramFold',
|
||||
json=json.dumps(
|
||||
{'type': 'approxHistogramFold', 'name': 'a_histogram'}),
|
||||
{'type': 'approxHistogramFold', 'name': 'a_histogram'},
|
||||
),
|
||||
),
|
||||
'aCustomMetric': DruidMetric(
|
||||
metric_name='aCustomMetric',
|
||||
verbose_name='MY_AWESOME_METRIC(*)',
|
||||
metric_type='aCustomType',
|
||||
json=json.dumps(
|
||||
{'type': 'customMetric', 'name': 'aCustomMetric'}),
|
||||
{'type': 'customMetric', 'name': 'aCustomMetric'},
|
||||
),
|
||||
),
|
||||
'quantile_p95': DruidMetric(
|
||||
metric_name='quantile_p95',
|
||||
verbose_name='P95(*)',
|
||||
@@ -365,7 +369,9 @@ class DruidTests(SupersetTestCase):
|
||||
'type': 'quantile',
|
||||
'probability': 0.95,
|
||||
'name': 'p95',
|
||||
'fieldName': 'a_histogram'})),
|
||||
'fieldName': 'a_histogram',
|
||||
}),
|
||||
),
|
||||
'aCustomPostAgg': DruidMetric(
|
||||
metric_name='aCustomPostAgg',
|
||||
verbose_name='CUSTOM_POST_AGG(*)',
|
||||
@@ -375,7 +381,10 @@ class DruidTests(SupersetTestCase):
|
||||
'name': 'aCustomPostAgg',
|
||||
'field': {
|
||||
'type': 'fieldAccess',
|
||||
'fieldName': 'aCustomMetric'}})),
|
||||
'fieldName': 'aCustomMetric',
|
||||
},
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
||||
metrics = ['some_sum']
|
||||
|
||||
@@ -89,8 +89,8 @@ class EmailSmtpTest(unittest.TestCase):
|
||||
'from', 'to', MIMEMultipart(), app.config, dryrun=False)
|
||||
assert not mock_smtp.called
|
||||
mock_smtp_ssl.assert_called_with(
|
||||
app.config.get('SMTP_HOST'),
|
||||
app.config.get('SMTP_PORT'),
|
||||
app.config.get('SMTP_HOST'),
|
||||
app.config.get('SMTP_PORT'),
|
||||
)
|
||||
|
||||
@mock.patch('smtplib.SMTP_SSL')
|
||||
@@ -104,8 +104,8 @@ class EmailSmtpTest(unittest.TestCase):
|
||||
'from', 'to', MIMEMultipart(), app.config, dryrun=False)
|
||||
assert not mock_smtp_ssl.called
|
||||
mock_smtp.assert_called_with(
|
||||
app.config.get('SMTP_HOST'),
|
||||
app.config.get('SMTP_PORT'),
|
||||
app.config.get('SMTP_HOST'),
|
||||
app.config.get('SMTP_PORT'),
|
||||
)
|
||||
assert not mock_smtp.login.called
|
||||
|
||||
|
||||
@@ -110,8 +110,10 @@ class UtilsTestCase(unittest.TestCase):
|
||||
self.assertEquals(form_data, expected)
|
||||
|
||||
def test_datetime_f(self):
|
||||
self.assertEquals(datetime_f(datetime(1990, 9, 21, 19, 11, 19, 626096)),
|
||||
'<nobr>1990-09-21T19:11:19.626096</nobr>')
|
||||
self.assertEquals(
|
||||
datetime_f(datetime(1990, 9, 21, 19, 11, 19, 626096)),
|
||||
'<nobr>1990-09-21T19:11:19.626096</nobr>',
|
||||
)
|
||||
self.assertEquals(len(datetime_f(datetime.now())), 28)
|
||||
self.assertEquals(datetime_f(None), '<nobr>None</nobr>')
|
||||
iso = datetime.now().isoformat()[:10].split('-')
|
||||
|
||||
@@ -545,7 +545,8 @@ class PartitionVizTestCase(unittest.TestCase):
|
||||
self.assertEqual(3, len(nest[0]['children']))
|
||||
self.assertEqual(3, len(nest[0]['children'][0]['children']))
|
||||
self.assertEqual(1, len(nest[0]['children'][0]['children'][0]['children']))
|
||||
self.assertEqual(1,
|
||||
self.assertEqual(
|
||||
1,
|
||||
len(nest[0]['children']
|
||||
[0]['children']
|
||||
[0]['children']
|
||||
|
||||
Reference in New Issue
Block a user