-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_bll_notifications_notification_seen.py
73 lines (58 loc) · 1.99 KB
/
test_bll_notifications_notification_seen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import time
from doajtest.helpers import DoajTestCase
from portality import models
from portality.bll import DOAJ
from portality.bll.exceptions import NoSuchObjectException
class TestBLLNotificationSeen(DoajTestCase):
def setUp(self):
super(TestBLLNotificationSeen, self).setUp()
def tearDown(self):
super(TestBLLNotificationSeen, self).tearDown()
def test_01_notification_missing(self):
acc = models.Account()
acc.set_id("testuser")
n = models.Notification()
n.who = "testuser"
n.long = "my message"
n.short = "short note"
n.action = "/test"
n.classification = "test_class"
n.created_by = "test:notify"
n.save(blocking=True)
svc = DOAJ.notificationsService()
with self.assertRaises(NoSuchObjectException):
ns = svc.notification_seen(acc, "randomid")
def test_02_notification_successfully_seen(self):
acc = models.Account()
acc.set_id("testuser")
n = models.Notification()
n.who = "testuser"
n.long = "my message"
n.short = "short note"
n.action = "/test"
n.classification = "test_class"
n.created_by = "test:notify"
n.save(blocking=True)
svc = DOAJ.notificationsService()
ns = svc.notification_seen(acc, n.id)
assert ns
time.sleep(1)
n2 = models.Notification.pull(n.id)
assert n2.is_seen()
def test_02_not_owner(self):
acc = models.Account()
acc.set_id("testuser")
n = models.Notification()
n.who = "testuser2"
n.long = "my message"
n.short = "short note"
n.action = "/test"
n.classification = "test_class"
n.created_by = "test:notify"
n.save(blocking=True)
svc = DOAJ.notificationsService()
ns = svc.notification_seen(acc, n.id)
assert not ns
time.sleep(1)
n2 = models.Notification.pull(n.id)
assert not n2.is_seen()