tests: make tests insensible to postgres/sqlite (#45105)
This commit is contained in:
parent
e365818a35
commit
bb7858690b
|
@ -7,7 +7,7 @@ from django.urls import reverse
|
|||
from django.contrib.auth.models import User
|
||||
from django.test import override_settings
|
||||
|
||||
from corbo.models import Broadcast, Subscription
|
||||
from corbo.models import Announce, Broadcast, Subscription
|
||||
from corbo.utils import format_phonenumber
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
@ -160,10 +160,11 @@ def test_edit_announce(app, admin_user):
|
|||
edit_form['expiration_time'] = '2017-12-31 23:00:00'
|
||||
resp = edit_form.submit()
|
||||
assert resp.status_int == 302
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': 1}))
|
||||
announce = Announce.objects.get(title='First announce')
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
|
||||
|
||||
# simulate announce deliver
|
||||
broadcast = Broadcast.objects.get(announce__pk=1)
|
||||
broadcast = Broadcast.objects.get(announce__pk=announce.id)
|
||||
broadcast.deliver_time = '2017-03-30 20:00:00'
|
||||
broadcast.delivery_count = 1
|
||||
broadcast.save()
|
||||
|
@ -178,7 +179,7 @@ def test_edit_announce(app, admin_user):
|
|||
broadcast.delivery_count = 2
|
||||
broadcast.save()
|
||||
|
||||
resp = app.get('http://testserver/manage/announce/1/')
|
||||
resp = app.get('http://testserver/manage/announce/%s/' % announce.id)
|
||||
assert '<strong>Sent</strong> March 30, 2017, 8 p.m.' in resp
|
||||
assert 'to 2 destinations' in resp
|
||||
|
||||
|
@ -248,7 +249,8 @@ def test_email_announce(app, admin_user):
|
|||
assert 'Cancel' in resp
|
||||
resp = send_form.submit()
|
||||
assert resp.status_int == 302
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': '1'}))
|
||||
announce = Announce.objects.get(title='First announce')
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
|
||||
|
||||
@mock.patch('corbo.utils.requests.post')
|
||||
def test_sms_announce(mocked_post, app, admin_user, settings):
|
||||
|
@ -307,7 +309,8 @@ def test_sms_announce(mocked_post, app, admin_user, settings):
|
|||
mocked_response.json.return_value = {'err': 0, 'data': True}
|
||||
mocked_post.return_value = mocked_response
|
||||
resp = form.submit()
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': 1}))
|
||||
announce = Announce.objects.get(title='First announce')
|
||||
assert resp.location.endswith(reverse('view_announce', kwargs={'pk': announce.id}))
|
||||
resp = resp.follow()
|
||||
# make sure the form informs about the success
|
||||
assert 'SMS successfully sent' in resp
|
||||
|
|
Reference in New Issue