1+ from unittest import skip
2+
13from lib .core .exceptions import AppException
24from src .superannotate import SAClient
35from tests .integration .base import BaseTestCase
46
7+
58sa = SAClient ()
69
710
@@ -27,20 +30,18 @@ class TestPauseUserActivity(BaseTestCase):
2730 def setUp (self , * args , ** kwargs ):
2831 super ().setUp (* args , ** kwargs )
2932 uploaded , _ , _ = sa .attach_items (self .PROJECT_NAME , self .ATTACHMENT_LIST )
30- users = sa .list_users ()
31- self .scapegoat = [u for u in users if u ["role" ] == "Contributor" ][0 ]
32- sa .add_contributors_to_project (
33- self .PROJECT_NAME , [self .scapegoat ["email" ]], "QA"
34- )
3533
3634 def test_pause_and_resume_user_activity (self ):
35+ users = sa .list_users ()
36+ scapegoat = [
37+ u for u in users if u ["role" ] == "Contributor" and u ["state" ] == "Confirmed"
38+ ][0 ]
39+ sa .add_contributors_to_project (self .PROJECT_NAME , [scapegoat ["email" ]], "QA" )
3740 with self .assertLogs ("sa" , level = "INFO" ) as cm :
38- sa .pause_user_activity (
39- pk = self .scapegoat ["email" ], projects = [self .PROJECT_NAME ]
40- )
41+ sa .pause_user_activity (pk = scapegoat ["email" ], projects = [self .PROJECT_NAME ])
4142 assert (
4243 cm .output [0 ]
43- == f"INFO:sa:User with email { self . scapegoat ['email' ]} has been successfully paused"
44+ == f"INFO:sa:User with email { scapegoat ['email' ]} has been successfully paused"
4445 f" from the specified projects: { [self .PROJECT_NAME ]} ."
4546 )
4647 with self .assertRaisesRegexp (
@@ -50,21 +51,41 @@ def test_pause_and_resume_user_activity(self):
5051 sa .assign_items (
5152 self .PROJECT_NAME ,
5253 [i ["name" ] for i in self .ATTACHMENT_LIST ],
53- self . scapegoat ["email" ],
54+ scapegoat ["email" ],
5455 )
5556
5657 with self .assertLogs ("sa" , level = "INFO" ) as cm :
57- sa .resume_user_activity (
58- pk = self .scapegoat ["email" ], projects = [self .PROJECT_NAME ]
59- )
58+ sa .resume_user_activity (pk = scapegoat ["email" ], projects = [self .PROJECT_NAME ])
6059 assert (
6160 cm .output [0 ]
62- == f"INFO:sa:User with email { self . scapegoat ['email' ]} has been successfully unblocked"
61+ == f"INFO:sa:User with email { scapegoat ['email' ]} has been successfully unblocked"
6362 f" from the specified projects: { [self .PROJECT_NAME ]} ."
6463 )
6564
6665 sa .assign_items (
6766 self .PROJECT_NAME ,
6867 [i ["name" ] for i in self .ATTACHMENT_LIST ],
69- self . scapegoat ["email" ],
68+ scapegoat ["email" ],
7069 )
70+
71+ @skip ("For not send real email" )
72+ def test_pause_resume_pending_user (self ):
73+ pending_user = "satest2277@gmail.com"
74+ if pending_user not in [u ["email" ] for u in sa .list_users ()]:
75+ sa .invite_contributors_to_team (emails = [pending_user ])
76+ sa .add_contributors_to_project (self .PROJECT_NAME , [pending_user ], "QA" )
77+ with self .assertLogs ("sa" , level = "INFO" ) as cm :
78+ sa .pause_user_activity (pk = pending_user , projects = [self .PROJECT_NAME ])
79+ assert (
80+ cm .output [0 ]
81+ == f"INFO:sa:User with email { pending_user } has been successfully paused"
82+ f" from the specified projects: { [self .PROJECT_NAME ]} ."
83+ )
84+
85+ with self .assertLogs ("sa" , level = "INFO" ) as cm :
86+ sa .resume_user_activity (pk = pending_user , projects = [self .PROJECT_NAME ])
87+ assert (
88+ cm .output [0 ]
89+ == f"INFO:sa:User with email { pending_user } has been successfully unblocked"
90+ f" from the specified projects: { [self .PROJECT_NAME ]} ."
91+ )
0 commit comments