Code Duplication    Length = 10-12 lines in 3 locations

tests/test_charts_builder.py 3 locations

@@ 548-559 (lines=12) @@
545
    assert REDIRECT_MSG in str(res.data)
546
547
548
def test_update_invalid_config(monkeypatch, ctx, client):
549
    app, test = client
550
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
551
    view = get_json_config('inputs.json')
552
    readfunc = read(override=dict(view))
553
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
554
    res = test.post(
555
        url_for('jsondash.update', c_id=view['id']),
556
        data={'edit-raw': 'on'},
557
        follow_redirects=True)
558
    dom = pq(res.data)
559
    assert dom.find('.alert-danger').text() == 'Error: Invalid JSON config.'
560
561
562
def test_update_valid(monkeypatch, ctx, client):
@@ 376-386 (lines=11) @@
373
    assert 'Invalid configuration - missing modules.' in str(res.data)
374
375
376
def test_get_view_valid_id_ensure__id_popped(monkeypatch, ctx, client):
377
    app, test = client
378
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
379
    view = get_json_config('inputs.json')
380
    view = dict(view)
381
    view.update(_id='foo')
382
    readfunc = read(override=view)
383
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
384
    res = test.get(url_for('jsondash.view', c_id=view['id']))
385
    dom = pq(res.data)
386
    assert len(dom.find('.item')) == len(view['modules'])
387
388
389
def test_view_valid_dashboard_count_and_inputs(monkeypatch, ctx, client):
@@ 389-398 (lines=10) @@
386
    assert len(dom.find('.item')) == len(view['modules'])
387
388
389
def test_view_valid_dashboard_count_and_inputs(monkeypatch, ctx, client):
390
    app, test = client
391
    monkeypatch.setattr(charts_builder, 'auth', auth_valid)
392
    view = get_json_config('inputs.json')
393
    readfunc = read(override=dict(view))
394
    monkeypatch.setattr(charts_builder.adapter, 'read', readfunc)
395
    res = test.get(url_for('jsondash.view', c_id=view['id']))
396
    dom = pq(res.data)
397
    assert len(dom.find('.item')) == len(view['modules'])
398
    assert len(dom.find('.charts-input-icon')) == 1
399
400
401
def test_view_valid_dashboard_inputs_form(monkeypatch, ctx, client):