forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_tests.py
63 lines (49 loc) · 2.18 KB
/
core_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import imp
import doctest
import os
import unittest
os.environ['DASHED_CONFIG'] = 'tests.dashed_test_config'
from flask.ext.testing import LiveServerTestCase, TestCase
import dashed
from dashed import app, db, models, utils
BASE_DIR = app.config.get("BASE_DIR")
cli = imp.load_source('cli', BASE_DIR + "/bin/dashed")
class LiveTest(TestCase):
def create_app(self):
app.config['LIVESERVER_PORT'] = 8873
app.config['TESTING'] = True
return app
def setUp(self):
pass
def test_init(self):
utils.init(dashed)
def test_load_examples(self):
cli.load_examples(sample=True)
def test_slices(self):
# Testing by running all the examples
Slc = models.Slice
for slc in db.session.query(Slc).all():
print(slc)
self.client.get(slc.slice_url)
viz = slc.viz
self.client.get(viz.get_url())
if hasattr(viz, 'get_json'):
self.client.get(viz.get_json())
def test_csv(self):
self.client.get('/dashed/explore/table/1/?viz_type=table&granularity=ds&since=100+years&until=now&metrics=count&groupby=name&limit=50&show_brush=y&show_brush=false&show_legend=y&show_brush=false&rich_tooltip=y&show_brush=false&show_brush=false&show_brush=false&show_brush=false&y_axis_format=&x_axis_showminmax=y&show_brush=false&line_interpolation=linear&rolling_type=None&rolling_periods=&time_compare=&num_period_compare=&where=&having=&flt_col_0=gender&flt_op_0=in&flt_eq_0=&flt_col_0=gender&flt_op_0=in&flt_eq_0=&slice_id=14&slice_name=Boys&collapsed_fieldsets=&action=&datasource_name=birth_names&datasource_id=1&datasource_type=table&previous_viz_type=line&csv=true')
def test_dashboard(self):
for dash in db.session.query(models.Dashboard).all():
self.client.get(dash.url)
def test_doctests(self):
modules = [utils]
for mod in modules:
failed, tests = doctest.testmod(mod)
if failed:
raise Exception("Failed a doctest")
def misc(self):
self.client.get('/health')
self.client.get('/ping')
def tearDown(self):
pass
if __name__ == '__main__':
unittest.main()