Projet

Général

Profil

« Précédent | Suivant » 

Révision bb785869

Ajouté par Nicolas Roche il y a presque 4 ans

tests: make tests insensible to postgres/sqlite (#45105)

Voir les différences:

tests/test_manager.py
7 7
from django.contrib.auth.models import User
8 8
from django.test import override_settings
9 9

  
10
from corbo.models import Broadcast, Subscription
10
from corbo.models import Announce, Broadcast, Subscription
11 11
from corbo.utils import format_phonenumber
12 12

  
13 13
pytestmark = pytest.mark.django_db
......
160 160
    edit_form['expiration_time'] = '2017-12-31 23:00:00'
161 161
    resp = edit_form.submit()
162 162
    assert resp.status_int == 302
163
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': 1}))
163
    announce = Announce.objects.get(title='First announce')
164
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
164 165

  
165 166
    # simulate announce deliver
166
    broadcast = Broadcast.objects.get(announce__pk=1)
167
    broadcast = Broadcast.objects.get(announce__pk=announce.id)
167 168
    broadcast.deliver_time = '2017-03-30 20:00:00'
168 169
    broadcast.delivery_count = 1
169 170
    broadcast.save()
......
178 179
    broadcast.delivery_count = 2
179 180
    broadcast.save()
180 181

  
181
    resp = app.get('http://testserver/manage/announce/1/')
182
    resp = app.get('http://testserver/manage/announce/%s/' % announce.id)
182 183
    assert '<strong>Sent</strong> March 30, 2017, 8 p.m.' in resp
183 184
    assert 'to 2 destinations' in resp
184 185

  
......
248 249
    assert 'Cancel' in resp
249 250
    resp = send_form.submit()
250 251
    assert resp.status_int == 302
251
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': '1'}))
252
    announce = Announce.objects.get(title='First announce')
253
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
252 254

  
253 255
@mock.patch('corbo.utils.requests.post')
254 256
def test_sms_announce(mocked_post, app, admin_user, settings):
......
307 309
    mocked_response.json.return_value = {'err': 0, 'data': True}
308 310
    mocked_post.return_value = mocked_response
309 311
    resp = form.submit()
310
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': 1}))
312
    announce = Announce.objects.get(title='First announce')
313
    assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
311 314
    resp = resp.follow()
312 315
    # make sure the form informs about the success
313 316
    assert 'SMS successfully sent' in resp

Formats disponibles : Unified diff