Completed
Push — master ( b02095...4e4277 )
by Chris
01:25
created

update()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 1
c 4
b 0
f 0
dl 0
loc 2
rs 10
1
import json
2
from datetime import datetime as dt
3
4
from flask import (
5
    Flask,
6
    current_app,
7
    url_for,
8
)
9
import pytest
10
11
from flask_jsondash import charts_builder
12
13
URL_BASE = 'http://127.0.0.1:80'
14
app = Flask('test_flask_jsondash',
15
            template_folder='../flask_jsondash/example_app/templates')
16
app.config.update(
17
    SECRET_KEY='123',
18
)
19
app.debug = True
20
app.register_blueprint(charts_builder.charts)
21
22
23
def _username():
24
    return 'Username'
25
26
27
def auth_ok(**kwargs):
28
    return True
29
30
31
def _authtest(**kwargs):
32
    return False
33
34
35
def read(*args, **kwargs):
36
    return dict()
37
38
39
def update(*args, **kwargs):
40
    return dict()
41
42
43
@pytest.fixture()
44
def ctx(monkeypatch, request):
45
    with app.test_request_context() as req_ctx:
46
        monkeypatch.setattr(charts_builder.adapter, 'read', read)
47
        monkeypatch.setattr(charts_builder.adapter, 'update', update)
48
        yield req_ctx
49
50
51
@pytest.fixture()
52
def client():
53
    app.config.update(
54
        JSONDASH_GLOBALDASH=False,
55
        JSONDASH_FILTERUSERS=False,
56
        JSONDASH_GLOBAL_USER='global-test',
57
    )
58
    app.config['JSONDASH'] = dict(
59
        metadata=dict(
60
            created_by=_username,
61
            username=_username,
62
        ),
63
        static=dict(
64
            js_path='js/vendor/',
65
            css_path='css/vendor/',
66
        ),
67
        auth=dict(
68
            edit_others=_authtest,
69
            edit_global=_authtest,
70
            create=_authtest,
71
            view=_authtest,
72
            clone=_authtest,
73
            delete=_authtest,
74
        )
75
    )
76
    return app, app.test_client()
77