71 |
71 |
|
72 |
72 |
item.perform(formdata)
|
73 |
73 |
assert http_requests.count() == 1
|
74 |
|
assert http_requests.get_last('url') == 'https://portal/api/notification/add/?NameID=xxx'
|
|
74 |
assert http_requests.get_last('url') == 'https://portal/api/notification/add/'
|
75 |
75 |
assert json.loads(http_requests.get_last('body')) == {
|
76 |
76 |
'body': 'XXX',
|
77 |
77 |
'url': formdata.get_url(),
|
78 |
78 |
'id': 'formdata:%s' % formdata.get_display_id(),
|
79 |
79 |
'origin': '',
|
80 |
80 |
'summary': 'xxx',
|
|
81 |
'name_ids': ['xxx'],
|
81 |
82 |
}
|
82 |
83 |
|
83 |
84 |
# deleted user
|
... | ... | |
108 |
109 |
|
109 |
110 |
item.to = ['_receiver']
|
110 |
111 |
item.perform(formdata)
|
111 |
|
assert http_requests.count() == 2
|
112 |
|
assert {x['url'] for x in http_requests.requests} == {
|
113 |
|
'https://portal/api/notification/add/?NameID=xxy1',
|
114 |
|
'https://portal/api/notification/add/?NameID=xxy2',
|
115 |
|
}
|
|
112 |
assert http_requests.count() == 1
|
|
113 |
assert http_requests.get_last('url') == 'https://portal/api/notification/add/'
|
|
114 |
assert set(json.loads(http_requests.get_last('body'))['name_ids']) == {'xxy1', 'xxy2'}
|
116 |
115 |
|
117 |
116 |
# test inactive users are ignored
|
118 |
117 |
user2.is_active = False
|
... | ... | |
120 |
119 |
http_requests.empty()
|
121 |
120 |
item.perform(formdata)
|
122 |
121 |
assert http_requests.count() == 1
|
123 |
|
assert {x['url'] for x in http_requests.requests} == {'https://portal/api/notification/add/?NameID=xxy1'}
|
|
122 |
assert http_requests.get_last('url') == 'https://portal/api/notification/add/'
|
|
123 |
assert set(json.loads(http_requests.get_last('body'))['name_ids']) == {'xxy1'}
|
|
124 |
|
|
125 |
user1.is_active = False
|
|
126 |
user1.store()
|
|
127 |
http_requests.empty()
|
|
128 |
item.perform(formdata)
|
|
129 |
assert http_requests.count() == 0
|
124 |
130 |
|
125 |
131 |
# check notifications are sent to interco portal if it exists
|
|
132 |
user1.is_active = True
|
|
133 |
user1.store()
|
126 |
134 |
pub.site_options.set('variables', '_interco_portal_url', 'https://interco-portal/')
|
127 |
135 |
http_requests.empty()
|
128 |
136 |
item.perform(formdata)
|
129 |
137 |
assert http_requests.count() == 1
|
130 |
|
assert {x['url'] for x in http_requests.requests} == {
|
131 |
|
'https://interco-portal/api/notification/add/?NameID=xxy1'
|
132 |
|
}
|
|
138 |
assert http_requests.get_last('url') == 'https://interco-portal/api/notification/add/'
|
|
139 |
assert set(json.loads(http_requests.get_last('body'))['name_ids']) == {'xxy1'}
|