2015-09-26 18:55:33 -04:00
|
|
|
import imp
|
2016-02-10 12:34:09 -05:00
|
|
|
import doctest
|
2015-09-26 18:55:33 -04:00
|
|
|
import os
|
|
|
|
import unittest
|
2016-03-18 02:44:58 -04:00
|
|
|
os.environ['DASHED_CONFIG'] = 'tests.dashed_test_config'
|
2015-09-26 18:55:33 -04:00
|
|
|
from flask.ext.testing import LiveServerTestCase, TestCase
|
|
|
|
|
2016-03-18 02:44:58 -04:00
|
|
|
import dashed
|
|
|
|
from dashed import app, db, models, utils
|
2015-09-26 18:55:33 -04:00
|
|
|
BASE_DIR = app.config.get("BASE_DIR")
|
2016-03-18 02:44:58 -04:00
|
|
|
cli = imp.load_source('cli', BASE_DIR + "/bin/dashed")
|
2015-09-26 18:55:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
class LiveTest(TestCase):
|
|
|
|
|
|
|
|
def create_app(self):
|
|
|
|
app.config['LIVESERVER_PORT'] = 8873
|
|
|
|
app.config['TESTING'] = True
|
|
|
|
return app
|
|
|
|
|
|
|
|
def setUp(self):
|
2015-09-29 00:31:04 -04:00
|
|
|
pass
|
2015-09-26 18:55:33 -04:00
|
|
|
|
2015-09-22 14:36:54 -04:00
|
|
|
def test_init(self):
|
2016-03-18 02:44:58 -04:00
|
|
|
utils.init(dashed)
|
2015-09-22 14:36:54 -04:00
|
|
|
|
2015-09-26 18:55:33 -04:00
|
|
|
def test_load_examples(self):
|
|
|
|
cli.load_examples(sample=True)
|
|
|
|
|
|
|
|
def test_slices(self):
|
2016-02-10 09:56:35 -05:00
|
|
|
# Testing by running all the examples
|
2015-09-26 18:55:33 -04:00
|
|
|
Slc = models.Slice
|
|
|
|
for slc in db.session.query(Slc).all():
|
2016-01-13 20:19:12 -05:00
|
|
|
print(slc)
|
2015-09-26 18:55:33 -04:00
|
|
|
self.client.get(slc.slice_url)
|
|
|
|
viz = slc.viz
|
2015-09-29 00:31:04 -04:00
|
|
|
self.client.get(viz.get_url())
|
2015-09-26 18:55:33 -04:00
|
|
|
if hasattr(viz, 'get_json'):
|
|
|
|
self.client.get(viz.get_json())
|
|
|
|
|
2015-12-17 21:08:43 -05:00
|
|
|
def test_csv(self):
|
2016-03-18 02:44:58 -04:00
|
|
|
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')
|
2015-12-17 21:08:43 -05:00
|
|
|
|
2015-09-26 18:55:33 -04:00
|
|
|
def test_dashboard(self):
|
|
|
|
for dash in db.session.query(models.Dashboard).all():
|
|
|
|
self.client.get(dash.url)
|
|
|
|
|
2016-02-10 12:34:09 -05:00
|
|
|
def test_doctests(self):
|
|
|
|
modules = [utils]
|
|
|
|
for mod in modules:
|
|
|
|
failed, tests = doctest.testmod(mod)
|
|
|
|
if failed:
|
|
|
|
raise Exception("Failed a doctest")
|
|
|
|
|
2016-03-27 17:23:33 -04:00
|
|
|
def misc(self):
|
|
|
|
self.client.get('/health')
|
|
|
|
self.client.get('/ping')
|
|
|
|
|
2015-09-26 18:55:33 -04:00
|
|
|
def tearDown(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|