Skip to content

Commit

Permalink
Test that coverage actually works
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Mar 27, 2016
1 parent 0a8a1ed commit 986b591
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dashed/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
},
Expand Down
11 changes: 6 additions & 5 deletions dashed/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 16 additions & 10 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
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
app.config['TESTING'] = True
return app

def setUp(self):
pass
self.client = self.create_app().test_client()

def test_init(self):
utils.init(dashed)
Expand All @@ -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)
Expand Down

0 comments on commit 986b591

Please sign in to comment.