Completed
Push — master ( 0ff6d7...2aa92f )
by Chris
01:05
created

make_count()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A count() 0 2 1
1
from flask import (
2
    Flask,
3
    current_app,
4
    url_for,
5
)
6
7
from flask_jsondash import charts_builder
8
9
10
def make_count(num=1000):
11
    def count(*args, **kwargs):
12
        return num
13
    return count
14
15
16
def make_setting(num=30):
17
    def setting(*args, **kwargs):
18
        return 30
19
    return setting
20
21
22 View Code Duplication
def test_paginator_default(monkeypatch, client):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
23
    app, test = client
24
    with app.app_context():
25
        monkeypatch.setattr(charts_builder, 'setting', make_setting(30))
26
        monkeypatch.setattr(charts_builder.adapter, 'count', make_count(1000))
27
        paginator = charts_builder.paginator(0)
28
        assert isinstance(paginator, charts_builder.Paginator)
29
        assert paginator.limit == 30
30
        assert paginator.per_page == 30
31
        assert paginator.curr_page == 0
32
        assert paginator.skip == 0
33
        assert paginator.num_pages == range(1, 35)
34
        assert paginator.count == 1000
35
36
37 View Code Duplication
def test_paginator_norecords(monkeypatch, client):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
38
    app, test = client
39
    with app.app_context():
40
        monkeypatch.setattr(charts_builder, 'setting', make_setting(30))
41
        monkeypatch.setattr(charts_builder.adapter, 'count', make_count(0))
42
        paginator = charts_builder.paginator(0)
43
        assert isinstance(paginator, charts_builder.Paginator)
44
        assert paginator.limit == 30
45
        assert paginator.per_page == 30
46
        assert paginator.curr_page == 0
47
        assert paginator.skip == 0
48
        assert paginator.num_pages == []
49
        assert paginator.count == 0
50