Projet

Général

Profil

0003-misc-allow-running-with-django-1.11-15973.patch

Frédéric Péters, 24 avril 2017 14:06

Télécharger (6,79 ko)

Voir les différences:

Subject: [PATCH 3/4] misc: allow running with django 1.11 (#15973)

 setup.py              |  2 +-
 tests/test_manager.py | 29 ++++++++++++-----------------
 tests/test_sso.py     |  6 +++---
 3 files changed, 16 insertions(+), 21 deletions(-)
setup.py
102 102
        'Programming Language :: Python',
103 103
        'Programming Language :: Python :: 2',
104 104
    ],
105
    install_requires=['django>=1.8, <1.9',
105
    install_requires=['django>=1.8, <1.12',
106 106
        'gadjo',
107 107
        'djangorestframework>=3.1',
108 108
        'django-jsonfield >= 0.9.3',
tests/test_manager.py
51 51

  
52 52
def test_unlogged_access(app):
53 53
    # connect while not being logged in
54
    assert app.get('/manage/', status=302).location == 'http://testserver/login/?next=/manage/'
54
    assert app.get('/manage/', status=302).location.endswith('/login/?next=/manage/')
55 55

  
56 56
def test_simple_user_access(app, simple_user):
57 57
    # connect while being logged as a simple user, access should be forbidden
......
79 79
    assert app.get('/manage/', status=200)
80 80

  
81 81
def test_home_redirect(app):
82
    assert app.get('/', status=302).location == 'http://testserver/manage/'
82
    assert app.get('/', status=302).location.endswith('/manage/')
83 83

  
84 84
def test_access(app, admin_user):
85 85
    app = login(app)
......
90 90
def test_logout(app, admin_user):
91 91
    app = login(app)
92 92
    app.get('/logout/')
93
    assert app.get('/manage/', status=302).location == 'http://testserver/login/?next=/manage/'
94

  
95
def test_logout_next(app, admin_user):
96
    app = login(app)
97
    app.get('/logout/')
98
    assert app.get('/manage/', status=302).location == 'http://testserver/login/?next=/manage/'
93
    assert app.get('/manage/', status=302).location.endswith('/login/?next=/manage/')
99 94

  
100 95
def test_menu_json(app, admin_user):
101 96
    app = login(app)
......
129 124
    resp = resp.form.submit()
130 125

  
131 126
    agenda = Agenda.objects.get(label='Foo bar')
132
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
127
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
133 128
    resp = resp.follow()
134 129
    assert '<h2>Foo bar' in resp.body
135 130

  
......
153 148
    assert resp.form['label'].value == 'Foo bar'
154 149
    resp.form['label'] = 'Foo baz'
155 150
    resp = resp.form.submit()
156
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
151
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
157 152
    resp = resp.follow()
158 153
    assert '<h2>Foo baz' in resp.body
159 154

  
......
176 171
    assert resp.form['label'].value == 'Foo bar'
177 172
    resp.form['label'] = 'Foo baz'
178 173
    resp = resp.form.submit()
179
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
174
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
180 175
    resp = resp.follow()
181 176
    assert '<h2>Foo baz' in resp.body
182 177

  
......
188 183
    resp = resp.click('Foo bar')
189 184
    resp = resp.click('Delete')
190 185
    resp = resp.form.submit()
191
    assert resp.location == 'http://testserver/manage/'
186
    assert resp.location.endswith('/manage/')
192 187
    resp = resp.follow()
193 188
    assert not 'Foo bar' in resp.body
194 189

  
......
380 375
    resp = resp.click(href='/manage/events/%s' % event.id)
381 376
    resp = resp.click('Delete')
382 377
    resp = resp.form.submit()
383
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
378
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
384 379
    assert Event.objects.count() == 0
385 380

  
386 381
def test_delete_busy_event(app, admin_user):
......
429 424
    resp = resp.click(href='/manage/events/%s' % event.id)
430 425
    resp = resp.click('Delete')
431 426
    resp = resp.form.submit()
432
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
427
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
433 428
    assert Event.objects.count() == 0
434 429

  
435 430
def test_import_events(app, admin_user):
......
517 512
    resp.form['kind'] = 'meetings'
518 513
    resp = resp.form.submit()
519 514
    agenda = Agenda.objects.get(label='Foo bar')
520
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
515
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
521 516
    resp = resp.follow()
522 517
    assert '<h2>Foo bar' in resp.body
523 518
    assert 'Meeting Types' in resp.body
......
557 552
    resp = resp.click('Blah')
558 553
    resp = resp.click('Delete')
559 554
    resp = resp.form.submit()
560
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
555
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
561 556
    assert MeetingType.objects.count() == 0
562 557

  
563 558
def test_meetings_agenda_add_time_period(app, admin_user):
......
610 605
    resp = resp.click('Wednesday')
611 606
    resp = resp.click('Delete')
612 607
    resp = resp.form.submit()
613
    assert resp.location == 'http://testserver/manage/agendas/%s/' % agenda.id
608
    assert resp.location.endswith('/manage/agendas/%s/' % agenda.id)
614 609
    assert TimePeriod.objects.count() == 0
tests/test_sso.py
10 10
def test_sso(app):
11 11
    with override_settings(MELLON_IDENTITY_PROVIDERS=[{'METADATA': 'x', 'ENTITY_ID': 'x'}]):
12 12
        resp = app.get('/login/')
13
        assert resp.location == 'http://testserver/accounts/mellon/login/'
13
        assert resp.location.endswith('/accounts/mellon/login/')
14 14

  
15 15
        resp = app.get('/login/?next=/manage/')
16
        assert resp.location == 'http://testserver/accounts/mellon/login/?next=/manage/'
16
        assert resp.location.endswith('/accounts/mellon/login/?next=/manage/')
17 17

  
18 18
def test_slo(app):
19 19
    with override_settings(MELLON_IDENTITY_PROVIDERS=[{'METADATA': 'x', 'ENTITY_ID': 'x'}]):
20 20
        resp = app.get('/logout/')
21
        assert resp.location == 'http://testserver/accounts/mellon/logout/'
21
        assert resp.location.endswith('/accounts/mellon/logout/')
22
-