Projet

Général

Profil

0001-tests-move-visualization-creation-to-fixture-30854.patch

Valentin Deniaud, 03 janvier 2020 17:21

Télécharger (3,38 ko)

Voir les différences:

Subject: [PATCH 1/2] tests: move visualization creation to fixture (#30854)

 tests/test_views.py | 55 +++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 34 deletions(-)
tests/test_views.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import pytest
18

  
17 19
from django.core.urlresolvers import reverse
18 20

  
19 21
from bijoe.visualization.models import Visualization
......
21 23
from utils import login
22 24

  
23 25

  
26
@pytest.fixture
27
def visualization():
28
    return Visualization.objects.create(
29
        name='test',
30
        parameters={
31
            'cube': 'facts1',
32
            'warehouse': 'schema1',
33
            'measure': 'simple_count',
34
            'representation': 'table',
35
            'loop': '',
36
            'filters': {},
37
            'drilldown_x': 'date__yearmonth'})
38

  
39

  
24 40
def test_simple_user_403(app, john_doe):
25 41
    login(app, john_doe)
26 42
    app.get('/', status=403)
......
45 61
    assert set([x['slug'] for x in resp.json]) == set(['test', 'test-2', 'test-3'])
46 62

  
47 63

  
48
def test_visualization_json_api(schema1, app, admin):
49
    visualization = Visualization(
50
            name='test',
51
            parameters={
52
                'cube': 'facts1',
53
                'warehouse': 'schema1',
54
                'measure': 'simple_count',
55
                'representation': 'table',
56
                'loop': '',
57
                'filters': {},
58
                'drilldown_x': 'date__yearmonth'})
59
    visualization.save()
60

  
64
def test_visualization_json_api(schema1, app, admin, visualization):
61 65
    login(app, admin)
62 66
    resp = app.get(reverse('visualization-json', kwargs={'pk': visualization.id}))
63 67
    # values from test_schem1/test_yearmonth_drilldown
......
70 74
    }
71 75

  
72 76

  
73
def test_visualization_json_api_duration(schema1, app, admin):
74
    visualization = Visualization(
75
        name='test',
76
        parameters={
77
            'cube': 'facts1',
78
            'warehouse': 'schema1',
79
            'measure': 'duration',
80
            'representation': 'table',
81
            'loop': '',
82
            'filters': {},
83
            'drilldown_x': 'date__yearmonth'})
77
def test_visualization_json_api_duration(schema1, app, admin, visualization):
78
    visualization.parameters['measure'] = 'duration'
84 79
    visualization.save()
85 80

  
86 81
    login(app, admin)
......
95 90
    }
96 91

  
97 92

  
98
def test_missing_data(schema1, app, admin):
99
    visualization = Visualization(
100
        name='test',
101
        parameters={
102
            'cube': 'missing_cube',
103
            'warehouse': 'schema1',
104
            'measure': 'duration',
105
            'representation': 'table',
106
            'loop': '',
107
            'filters': {}})
93
def test_missing_data(schema1, app, admin, visualization):
94
    visualization.parameters['cube'] = 'missing_cube'
108 95
    visualization.save()
109 96
    login(app, admin)
110 97

  
111
-