diff --git a/.travis.yml b/.travis.yml index b51f0f3c0af4b..ea97c9735e636 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,14 @@ python: cache: directories: - $HOME/.wheelhouse/ +before_install: + - rm -rf ~/.npm + - mkdir ~/.npm install: - pip wheel -w $HOME/.wheelhouse -f $HOME/.wheelhouse -r requirements.txt - pip install --find-links=$HOME/.wheelhouse --no-index -rrequirements.txt - python setup.py install - cd dashed/assets - - "touch $HOME/.npm/foo.lock; rm -f $HOME/.npm/*.lock" - npm install - npm run prod - cd $TRAVIS_BUILD_DIR diff --git a/dashed/assets/package.json b/dashed/assets/package.json index 4017399df200b..d0bab9fa7c1e3 100644 --- a/dashed/assets/package.json +++ b/dashed/assets/package.json @@ -9,7 +9,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "webpack -d --watch --colors", - "prod": "webpack -p --colors", + "prod": "webpack -p --colors --progress", "lint": "npm run --silent lint:js", "lint:js": "eslint --ignore-path=.eslintignore --ext .js ." }, diff --git a/dashed/models.py b/dashed/models.py index 0505402864f6f..2237628935f8f 100644 --- a/dashed/models.py +++ b/dashed/models.py @@ -122,9 +122,12 @@ class Slice(Model, AuditMixinNullable): cache_timeout = Column(Integer) table = relationship( - 'SqlaTable', foreign_keys=[table_id], backref='slices') + 'SqlaTable', foreign_keys=[table_id], backref='slices', + lazy='subquery') druid_datasource = relationship( - 'DruidDatasource', foreign_keys=[druid_datasource_id], backref='slices') + 'DruidDatasource', foreign_keys=[druid_datasource_id], + backref='slices', + lazy='subquery') def __repr__(self): return self.slice_name @@ -151,9 +154,7 @@ def datasource_edit_url(self): @utils.memoized def viz(self): d = json.loads(self.params) - viz = viz_types[self.viz_type]( - self.datasource, - form_data=d) + viz = viz_types[self.viz_type](self.datasource, form_data=d) return viz @property diff --git a/tests/core_tests.py b/tests/core_tests.py index dd936bb868c36..b62ff9c02664d 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -6,12 +6,12 @@ from flask.ext.testing import LiveServerTestCase, TestCase import dashed -from dashed import app, db, models, utils +from dashed import app, db, models, utils, get_session BASE_DIR = app.config.get("BASE_DIR") cli = imp.load_source('cli', BASE_DIR + "/bin/dashed") -class LiveTest(TestCase): +class LiveTest(unittest.TestCase): def create_app(self): app.config['LIVESERVER_PORT'] = 8873 @@ -19,7 +19,7 @@ def create_app(self): return app def setUp(self): - pass + self.client = self.create_app().test_client() def test_init(self): utils.init(dashed) @@ -30,17 +30,23 @@ def test_load_examples(self): 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()) + session = get_session() + urls = [] + for slc in session.query(Slc).all(): + urls.append(slc.slice_url) + urls.append(slc.viz.json_endpoint) + for url in urls: + self.client.get(url) + session.commit() + session.close() 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 misc(self): + self.client.get('/health') + self.client.get('/ping') + def test_dashboard(self): for dash in db.session.query(models.Dashboard).all(): self.client.get(dash.url)