Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
christabor committed May 26, 2017
1 parent 0d956d9 commit d7418f4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def setup_dashboard(monkeypatch, app, test, data):
return dom


def make_chart(**kwargs):
"""Create a fake chart."""
data = dict(
name='somechart',
width=1,
height=1,
family='C3',
type='line',
row=1,
dataSource='...',
)
data.update(**kwargs)
return json.dumps(data)


@pytest.yield_fixture
def ctx(monkeypatch, request):
with app.test_request_context() as req_ctx:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_charts_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
get_json_config,
auth_valid,
read,
setup_dashboard,
make_chart,
)

from flask_jsondash import charts_builder
Expand Down Expand Up @@ -421,3 +423,18 @@ def test_demo_mode(monkeypatch, ctx, client):
dom = pq(res.data)
assert not dom.find('.chart-header > small .btn')
assert not dom.find('.chart-header .dropdown-toggle')


def test_correct_charts_count(monkeypatch, ctx, client):
app, test = client
data = dict(
mode='grid',
name='Some dashboard - lots of cols and rows',
)
data.update({
'module_{}'.format(i): make_chart(row=1) for i in range(5)
})
dom = setup_dashboard(monkeypatch, app, test, data)
container = dom.find('#container')
assert len(container.find('.item.widget')) == 5
assert len(container.find('.item.widget').find('.widget-title-text')) == 5

0 comments on commit d7418f4

Please sign in to comment.