1
- import pytest
2
1
from sogs import db , utils
3
- import werkzeug .exceptions as wexc
4
2
from request import sogs_get , sogs_post
5
3
from util import pad64
6
4
import time
@@ -553,8 +551,8 @@ def test_bans(client, room, room2, user, user2, mod, global_mod):
553
551
r = sogs_post (client , url_ban , {'rooms' : ['test-room' ]}, mod )
554
552
assert r .status_code == 200
555
553
556
- with pytest . raises ( wexc . Forbidden ):
557
- sogs_post ( client , "/room/test-room/message" , post , user )
554
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
555
+ assert r . status_code == 403
558
556
559
557
r = sogs_post (client , "/room/test-room/message" , post , user2 )
560
558
assert r .status_code == 201
@@ -570,11 +568,11 @@ def test_bans(client, room, room2, user, user2, mod, global_mod):
570
568
r = sogs_post (client , url_ban , {'rooms' : ['*' ]}, global_mod )
571
569
assert r .status_code == 200
572
570
573
- with pytest . raises ( wexc . Forbidden ):
574
- sogs_post ( client , "/room/test-room/message" , post , user )
571
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
572
+ assert r . status_code == 403
575
573
576
- with pytest . raises ( wexc . Forbidden ):
577
- sogs_post ( client , "/room/room2/message" , post , user )
574
+ r = sogs_post ( client , "/room/room2/message" , post , user )
575
+ assert r . status_code == 403
578
576
579
577
r = sogs_post (client , "/room/test-room/message" , post , user2 )
580
578
assert r .status_code == 201
@@ -583,8 +581,8 @@ def test_bans(client, room, room2, user, user2, mod, global_mod):
583
581
584
582
r = sogs_post (client , "/room/test-room/message" , post , user )
585
583
assert r .status_code == 201
586
- with pytest . raises ( wexc . Forbidden ):
587
- r = sogs_post ( client , "/room/room2/message" , post , user )
584
+ r = sogs_post ( client , "/room/room2/message" , post , user )
585
+ assert r . status_code == 403
588
586
589
587
r = sogs_post (client , url_unban , {'rooms' : ['*' ]}, global_mod )
590
588
@@ -641,11 +639,11 @@ def test_ban_timeouts(client, room, room2, user, mod, global_mod):
641
639
r = sogs_post (client , url_ban , {'rooms' : ['*' ], 'timeout' : 0.001 }, global_mod )
642
640
assert r .status_code == 200
643
641
644
- with pytest . raises ( wexc . Forbidden ):
645
- sogs_post ( client , "/room/test-room/message" , post , user )
642
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
643
+ assert r . status_code == 403
646
644
647
- with pytest . raises ( wexc . Forbidden ):
648
- sogs_post ( client , "/room/room2/message" , post , user )
645
+ r = sogs_post ( client , "/room/room2/message" , post , user )
646
+ assert r . status_code == 403
649
647
650
648
from sogs .cleanup import cleanup
651
649
@@ -660,17 +658,18 @@ def test_ban_timeouts(client, room, room2, user, mod, global_mod):
660
658
r = sogs_post (client , url_ban , {'rooms' : ['*' ], 'timeout' : 30 }, mod )
661
659
assert r .status_code == 200
662
660
663
- with pytest . raises ( wexc . Forbidden ):
664
- sogs_post ( client , "/room/test-room/message" , post , user )
661
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
662
+ assert r . status_code == 403
665
663
666
664
r = sogs_post (client , "/room/room2/message" , post , user )
667
665
assert r .status_code == 201
668
666
669
667
# The timed ban shouldn't expire yet:
670
668
assert cleanup () == (0 , 0 , 0 , 0 , 0 )
671
669
672
- with pytest .raises (wexc .Forbidden ):
673
- sogs_post (client , "/room/test-room/message" , post , user )
670
+ r = sogs_post (client , "/room/test-room/message" , post , user )
671
+ assert r .status_code == 403
672
+
674
673
r = sogs_post (client , "/room/room2/message" , post , user )
675
674
assert r .status_code == 201
676
675
@@ -683,8 +682,8 @@ def test_ban_timeouts(client, room, room2, user, mod, global_mod):
683
682
r = sogs_post (client , url_ban , {'rooms' : ['*' ], 'timeout' : 0.001 }, mod )
684
683
assert r .status_code == 200
685
684
686
- with pytest . raises ( wexc . Forbidden ):
687
- sogs_post ( client , "/room/test-room/message" , post , user )
685
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
686
+ assert r . status_code == 403
688
687
689
688
time .sleep (0.002 )
690
689
assert cleanup () == (0 , 0 , 0 , 1 , 0 )
@@ -717,8 +716,8 @@ def test_ban_timeouts(client, room, room2, user, mod, global_mod):
717
716
718
717
assert cleanup () == (0 , 0 , 0 , 0 , 0 )
719
718
720
- with pytest . raises ( wexc . Forbidden ):
721
- sogs_post ( client , "/room/test-room/message" , post , user )
719
+ r = sogs_post ( client , "/room/test-room/message" , post , user )
720
+ assert r . status_code == 403
722
721
723
722
# Unbanning should remove the ban future
724
723
assert sogs_post (client , url_unban , {'rooms' : ['*' ]}, mod ).status_code == 200
0 commit comments