43 |
43 |
|
44 |
44 |
|
45 |
45 |
def test_notification_api(user, user2):
|
46 |
|
notification, created = Notification.notify(user, 'notifoo')
|
47 |
|
assert created
|
|
46 |
notification = Notification.notify(user, 'notifoo')
|
48 |
47 |
assert Notification.objects.count() == 1
|
49 |
48 |
assert notification.summary == 'notifoo'
|
50 |
49 |
assert notification.body == ''
|
... | ... | |
66 |
65 |
noti = Notification.objects.get()
|
67 |
66 |
assert noti.end_timestamp - noti.start_timestamp == timedelta(seconds=3600)
|
68 |
67 |
|
69 |
|
notification, created = Notification.notify(user, 'notibar', id='ns:notibar')
|
|
68 |
notification = Notification.notify(user, 'notibar', id='ns:notibar')
|
70 |
69 |
assert Notification.objects.count() == 2
|
71 |
|
notification, created = Notification.notify(user, 'notirebar', id='ns:notibar')
|
72 |
|
assert not created
|
|
70 |
notification = Notification.notify(user, 'notirebar', id='ns:notibar')
|
73 |
71 |
assert Notification.objects.count() == 2
|
74 |
72 |
|
75 |
|
notification, created = Notification.notify(user2, 'notiother')
|
|
73 |
notification = Notification.notify(user2, 'notiother')
|
76 |
74 |
notification.forget()
|
77 |
75 |
assert Notification.objects.filter(user=user2).count() == 1
|
78 |
76 |
notification = Notification.objects.filter(user=user2).get()
|
... | ... | |
94 |
92 |
assert cell.is_visible(context['request'].user) is True
|
95 |
93 |
assert cell.get_badge(context) is None
|
96 |
94 |
|
97 |
|
notification1, created = Notification.notify(user, 'notibar')
|
98 |
|
notification2, created = Notification.notify(user, 'notifoo')
|
|
95 |
notification1 = Notification.notify(user, 'notibar')
|
|
96 |
notification2 = Notification.notify(user, 'notifoo')
|
99 |
97 |
content = cell.render(context)
|
100 |
98 |
assert 'notibar' in content
|
101 |
99 |
assert 'notifoo' in content
|
... | ... | |
117 |
115 |
assert 'notiurl' in content
|
118 |
116 |
assert 'https://www.example.net/' in content
|
119 |
117 |
|
120 |
|
notification3, created = Notification.notify(user, 'ackme')
|
|
118 |
notification3 = Notification.notify(user, 'ackme')
|
121 |
119 |
notification3.ack()
|
122 |
120 |
content = cell.render(context)
|
123 |
121 |
assert 'acked' in content
|
... | ... | |
146 |
144 |
content_type='application/json')
|
147 |
145 |
assert resp.status_code == 200
|
148 |
146 |
result = json.loads(resp.content)
|
149 |
|
assert result == {'data': {'id': check_id, 'created': True}, 'err': 0}
|
|
147 |
assert result == {'data': {'id': check_id}, 'err': 0}
|
150 |
148 |
assert Notification.objects.filter(user=user).count() == count
|
151 |
149 |
return Notification.objects.find(user, check_id).get()
|
152 |
150 |
|
... | ... | |
247 |
245 |
result = notify({'summary': 'foo', 'id': '1'})
|
248 |
246 |
assert result['err'] == 1
|
249 |
247 |
|
250 |
|
notification, created = Notification.notify(user, 'foo')
|
|
248 |
notification = Notification.notify(user, 'foo')
|
251 |
249 |
|
252 |
250 |
result = notify({'summary': 'foo', 'id': str(notification.id)})
|
253 |
251 |
assert result['err'] == 0
|
254 |
|
-
|