Code Duplication    Length = 9-12 lines in 4 locations

tests/test_charts_builder.py 4 locations

@@ 273-284 (lines=12) @@
270
    assert len(read()) == 0
271
272
273
def test_update_edit_raw_invalid(monkeypatch, ctx, client):
274
    app, test = client
275
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
276
    view = get_json_config('inputs.json')
277
    readfunc = read(override=dict(view))
278
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
279
    res = test.post(
280
        url_for('jsondash.update', c_id=view['id']),
281
        data={'edit-raw': 'on'},
282
        follow_redirects=True)
283
    dom = pq(res.data)
284
    assert dom.find('.alert-danger').text() == 'Error: Invalid JSON config.'
285
286
287
def test_update_edit_raw_valid(monkeypatch, ctx, client):
@@ 101-111 (lines=11) @@
98
    assert 'Invalid configuration - missing modules.' in str(res.data)
99
100
101
def test_get_view_valid_id_ensure__id_popped(monkeypatch, ctx, client):
102
    app, test = client
103
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
104
    view = get_json_config('inputs.json')
105
    view = dict(view)
106
    view.update(_id='foo')
107
    readfunc = read(override=view)
108
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
109
    res = test.get(url_for('jsondash.view', c_id=view['id']))
110
    dom = pq(res.data)
111
    assert len(dom.find('.item')) == len(view['modules'])
112
113
114
def test_view_valid_dashboard_count_and_inputs(monkeypatch, ctx, client):
@@ 114-123 (lines=10) @@
111
    assert len(dom.find('.item')) == len(view['modules'])
112
113
114
def test_view_valid_dashboard_count_and_inputs(monkeypatch, ctx, client):
115
    app, test = client
116
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
117
    view = get_json_config('inputs.json')
118
    readfunc = read(override=dict(view))
119
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
120
    res = test.get(url_for('jsondash.view', c_id=view['id']))
121
    dom = pq(res.data)
122
    assert len(dom.find('.item')) == len(view['modules'])
123
    assert len(dom.find('.charts-input-icon')) == 1
124
125
126
def test_view_valid_dashboard_inputs_form(monkeypatch, ctx, client):
@@ 169-177 (lines=9) @@
166
    assert len(dom.find('.chart-inputs [type="checkbox"]')) == len(checkbox)
167
168
169
def test_get_view_valid_modules_valid_dash_title(monkeypatch, ctx, client):
170
    app, test = client
171
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
172
    view = get_json_config('inputs.json')
173
    readfunc = read(override=dict(view))
174
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
175
    res = test.get(url_for('jsondash.view', c_id=view['id']))
176
    dom = pq(res.data)
177
    assert dom.find('.dashboard-title').text() == view['name']
178
179
180
def test_create_valid(monkeypatch, ctx, client):