@@ -18,10 +18,12 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
18
18
19
19
seqno = r .json [- 1 ]["seqno" ]
20
20
21
+ new_seqno = seqno
21
22
for x in ("🖕" , "🍆" , "f" , "y/n" , "abcdefghijkl" ):
22
23
r = sogs_put (client , f"/room/test-room/reaction/4/{ x } " , {}, user )
23
24
assert r .status_code == 200
24
- assert r .json ["added" ]
25
+ new_seqno += 1
26
+ assert r .json == {"added" : True , "seqno" : new_seqno }
25
27
26
28
# Without the ?t=r flag, we don't get reaction-only updates:
27
29
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } " , user2 )
@@ -37,7 +39,7 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
37
39
# Already present:
38
40
r = sogs_put (client , "/room/test-room/reaction/4/🖕" , {}, user )
39
41
assert r .status_code == 200
40
- assert not r .json [ "added" ]
42
+ assert r .json == { "added" : False , "seqno" : seqno }
41
43
assert sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r" , user2 ).json == []
42
44
43
45
r = sogs_get (client , "/room/test-room/messages/since/0?t=r" , user2 )
@@ -46,14 +48,15 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
46
48
assert r .json [- 1 ]["seqno" ] == seqno
47
49
48
50
r = sogs_put (client , "/room/test-room/reaction/10/🍍" , {}, user )
49
- assert r .json [ "added" ]
51
+ assert r .json == { "added" : True , "seqno" : seqno + 1 }
50
52
r = sogs_put (client , "/room/test-room/reaction/4/🖕" , {}, user2 )
51
- assert r .json [ "added" ]
53
+ assert r .json == { "added" : True , "seqno" : seqno + 2 }
52
54
r = sogs_put (client , "/room/test-room/reaction/4/🍍" , {}, user )
53
- assert r .json [ "added" ]
55
+ assert r .json == { "added" : True , "seqno" : seqno + 3 }
54
56
55
57
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r" , user2 )
56
58
assert {x ['id' ]: x ['seqno' ] for x in r .json } == {4 : seqno + 3 , 10 : seqno + 1 }
59
+ seqno_10 = seqno + 1
57
60
seqno += 3
58
61
59
62
r = sogs_get (client , "/room/room2/messages/since/0?t=r" , user2 )
@@ -62,12 +65,17 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
62
65
# If there is both an edit and new reactions, we should get the full message including reactions
63
66
# and *not* a separate reactions row.
64
67
room .edit_post (mod , 4 , data = b'edited fake data 4' , sig = pad64 (b'fake sig 4b' ))
68
+ new_seqno = seqno + 1
65
69
for u in (user2 , global_admin , mod , global_mod , admin ):
66
70
r = sogs_put (client , "/room/test-room/reaction/4/🍍" , {}, u )
67
- assert r .json ['added' ]
68
- assert not sogs_put (client , "/room/test-room/reaction/4/🍍" , {}, user ).json ['added' ]
71
+ new_seqno += 1
72
+ assert r .json == {'added' : True , 'seqno' : new_seqno }
73
+ assert sogs_put (client , "/room/test-room/reaction/4/🍍" , {}, user ).json == {
74
+ 'added' : False ,
75
+ "seqno" : new_seqno ,
76
+ }
69
77
r = sogs_put (client , "/room/test-room/reaction/4/🦒🦍🐍🐊🦢🦁🦎" , {}, user )
70
- assert r .json [ 'added' ]
78
+ assert r .json == { 'added' : True , "seqno" : new_seqno + 1 }
71
79
72
80
exp_reactions = {
73
81
'abcdefghijkl' : {'index' : 4 , 'count' : 1 , 'reactors' : [user .session_id ]},
@@ -147,9 +155,8 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
147
155
148
156
r = sogs_delete (client , "/room/test-room/reactions/4/🍍" , global_admin )
149
157
assert r .status_code == 200
150
- n_pineapples = exp_reactions ["🍍" ]["count" ]
151
- assert r .json ["removed" ] == n_pineapples
152
- assert r .json ["removed" ] == 5
158
+ assert exp_reactions ["🍍" ]["count" ] == 5
159
+ assert r .json == {"removed" : 5 , "seqno" : seqno + 5 }
153
160
del exp_reactions ["🍍" ]
154
161
exp_reactions ["🦒🦍🐍🐊🦢🦁🦎" ]["index" ] -= 1
155
162
@@ -160,7 +167,7 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
160
167
n_other = sum (x ["count" ] for x in exp_reactions .values ())
161
168
r = sogs_delete (client , "/room/test-room/reactions/4" , mod )
162
169
assert r .status_code == 200
163
- assert r .json [ "removed" ] == n_other
170
+ assert r .json == { "removed" : n_other , "seqno" : seqno + n_other }
164
171
165
172
r = sogs_get (client , f"/room/test-room/messages/since/{ seqno } ?t=r&reactors=0" , user2 )
166
173
assert r .json == [{'id' : 4 , 'reactions' : {}, 'seqno' : seqno + n_other }]
@@ -172,11 +179,23 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
172
179
assert [x ['id' ] for x in r if x ['reactions' ]] == [10 ]
173
180
assert r [7 ]['reactions' ] == {'🍍' : {'count' : 1 , 'index' : 0 }}
174
181
175
- assert not sogs_delete (client , "/room/test-room/reaction/10/🍍" , global_mod ).json ['removed' ]
176
- assert sogs_delete (client , "/room/test-room/reaction/10/🍍" , user ).json ['removed' ]
182
+ assert sogs_delete (client , "/room/test-room/reaction/10/🍍" , global_mod ).json == {
183
+ 'removed' : False ,
184
+ 'seqno' : seqno_10 ,
185
+ }
186
+ assert sogs_delete (client , "/room/test-room/reaction/10/🍍" , user ).json == {
187
+ 'removed' : True ,
188
+ 'seqno' : seqno + 1 ,
189
+ }
177
190
178
- assert sogs_put (client , "/room/test-room/reaction/9/🍍" , {}, user ).json ['added' ]
179
- assert sogs_put (client , "/room/test-room/reaction/9/🍍" , {}, user2 ).json ['added' ]
191
+ assert sogs_put (client , "/room/test-room/reaction/9/🍍" , {}, user ).json == {
192
+ 'added' : True ,
193
+ "seqno" : seqno + 2 ,
194
+ }
195
+ assert sogs_put (client , "/room/test-room/reaction/9/🍍" , {}, user2 ).json == {
196
+ 'added' : True ,
197
+ "seqno" : seqno + 3 ,
198
+ }
180
199
r = sogs_get (client , "/room/test-room/message/9" , mod ).json
181
200
assert 'reactions' in r
182
201
assert r .get ('reactions' ) == {
@@ -263,27 +282,27 @@ def test_reaction_ordering(client, room, user, user2):
263
282
for x in ("🖕" , "f" , "🍆" , "y/n" , "abcdefghijkl" , "🍍" ):
264
283
r = sogs_put (client , f"/room/test-room/reaction/1/{ x } " , {}, user )
265
284
assert r .status_code == 200
266
- assert r .json ["added" ]
267
285
seqno += 1
286
+ assert r .json == {"added" : True , "seqno" : seqno }
268
287
269
288
for x in ("‽" , "abcdefghijkl" , "f" , "🍍" , "🖕" ):
270
289
r = sogs_put (client , f"/room/test-room/reaction/2/{ x } " , {}, user2 )
271
290
assert r .status_code == 200
272
- assert r .json ["added" ]
273
291
seqno += 1
292
+ assert r .json == {"added" : True , "seqno" : seqno }
274
293
275
294
for x in ("🖕" , "f" , "🍆" , "y/n" , "abcdefghijkl" , "🍍" , "🫑" ):
276
295
r = sogs_put (client , f"/room/test-room/reaction/2/{ x } " , {}, user )
277
296
assert r .status_code == 200
278
- assert r .json ["added" ]
279
297
seqno += 1
298
+ assert r .json == {"added" : True , "seqno" : seqno }
280
299
seqno_2 = seqno
281
300
282
301
for x in ("abcdefghijkl" , "f" , "🍍" , "🖕" , "🎂" ):
283
302
r = sogs_put (client , f"/room/test-room/reaction/1/{ x } " , {}, user2 )
284
303
assert r .status_code == 200
285
- assert r .json ["added" ]
286
304
seqno += 1
305
+ assert r .json == {"added" : True , "seqno" : seqno }
287
306
288
307
u1 = [user .session_id ]
289
308
u2 = [user2 .session_id ]
@@ -316,7 +335,10 @@ def test_reaction_ordering(client, room, user, user2):
316
335
]
317
336
318
337
# Deleting a user reaction while the post has other user reactions should not affect the order:
319
- assert sogs_delete (client , "/room/test-room/reaction/1/f" , user ).json ['removed' ]
338
+ assert sogs_delete (client , "/room/test-room/reaction/1/f" , user ).json == {
339
+ 'removed' : True ,
340
+ 'seqno' : seqno + 1 ,
341
+ }
320
342
seqno += 1
321
343
exp_reacts_1 ["f" ]["count" ] -= 1
322
344
exp_reacts_1 ["f" ]["reactors" ] = u2
@@ -329,8 +351,14 @@ def test_reaction_ordering(client, room, user, user2):
329
351
330
352
# Deleting the last reaction and then adding it again should put it back at the *end*, not in
331
353
# its original position:
332
- assert sogs_delete (client , "/room/test-room/reaction/1/f" , user2 ).json ['removed' ]
333
- assert sogs_put (client , "/room/test-room/reaction/1/f" , {}, user2 ).json ['added' ]
354
+ assert sogs_delete (client , "/room/test-room/reaction/1/f" , user2 ).json == {
355
+ 'removed' : True ,
356
+ 'seqno' : seqno + 1 ,
357
+ }
358
+ assert sogs_put (client , "/room/test-room/reaction/1/f" , {}, user2 ).json == {
359
+ 'added' : True ,
360
+ 'seqno' : seqno + 2 ,
361
+ }
334
362
seqno += 2
335
363
336
364
for v in exp_reacts_1 .values ():
0 commit comments