tests: update notifications to convert content before loading as json (#35425)
This commit is contained in:
parent
e5281adb2b
commit
58ee29aeb7
|
@ -7,6 +7,7 @@ from datetime import timedelta as timedelta
|
|||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test.client import RequestFactory
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.timezone import timedelta, now
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
@ -147,7 +148,7 @@ def test_notification_ws(john_doe):
|
|||
resp = client.post(reverse('api-notification-add'), json.dumps(data),
|
||||
content_type='application/json')
|
||||
assert resp.status_code == 200
|
||||
result = json.loads(resp.content)
|
||||
result = json.loads(force_text(resp.content))
|
||||
assert result == {'data': {'id': check_id}, 'err': 0}
|
||||
assert Notification.objects.filter(user=john_doe).count() == count
|
||||
return Notification.objects.find(john_doe, check_id).get()
|
||||
|
@ -196,18 +197,18 @@ def test_notification_ws(john_doe):
|
|||
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(resp.content)['new'] == 3
|
||||
assert json.loads(resp.content)['total'] == 3
|
||||
assert json.loads(force_text(resp.content))['new'] == 3
|
||||
assert json.loads(force_text(resp.content))['total'] == 3
|
||||
resp = client.get(reverse('api-notification-ack', kwargs={'notification_id': '1'}))
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(resp.content)['new'] == 2
|
||||
assert json.loads(resp.content)['total'] == 3
|
||||
assert json.loads(force_text(resp.content))['new'] == 2
|
||||
assert json.loads(force_text(resp.content))['total'] == 3
|
||||
resp = client.get(reverse('api-notification-forget', kwargs={'notification_id': '1'}))
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(resp.content)['new'] == 2
|
||||
assert json.loads(resp.content)['total'] == 2
|
||||
assert json.loads(force_text(resp.content))['new'] == 2
|
||||
assert json.loads(force_text(resp.content))['total'] == 2
|
||||
|
||||
def test_notification_ws_badrequest(john_doe):
|
||||
|
||||
|
@ -216,7 +217,7 @@ def test_notification_ws_badrequest(john_doe):
|
|||
json.dumps(data) if data else None,
|
||||
content_type='application/json')
|
||||
assert resp.status_code == 400
|
||||
result = json.loads(resp.content)
|
||||
result = json.loads(force_text(resp.content))
|
||||
assert result['err'] == 1
|
||||
assert message in list(result['err_desc'].values())[0][0]
|
||||
|
||||
|
@ -258,7 +259,7 @@ def test_notification_id_and_origin(john_doe):
|
|||
resp = client.post(reverse('api-notification-add'), json.dumps(data),
|
||||
content_type='application/json')
|
||||
|
||||
return json.loads(resp.content)
|
||||
return json.loads(force_text(resp.content))
|
||||
|
||||
result = notify({'summary': 'foo', 'id': '1'})
|
||||
assert result['err'] == 1
|
||||
|
|
Loading…
Reference in New Issue