Skip to content

Commit cca2263

Browse files
authored
Merge pull request #746 from superannotateai/test_pause
added test_pause_resume_pending_user
2 parents fe0f32e + 53dec54 commit cca2263

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from lib.app.serializers import SettingsSerializer
4444
from lib.app.serializers import TeamSerializer
4545
from lib.core import LIMITED_FUNCTIONS
46-
from lib.core.entities.work_managament import WMUserTypeEnum
4746
from lib.core import entities
4847
from lib.core.conditions import CONDITION_EQ as EQ
4948
from lib.core.conditions import Condition

tests/integration/work_management/test_pause_resume_user_activity.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from unittest import skip
2+
13
from lib.core.exceptions import AppException
24
from src.superannotate import SAClient
35
from tests.integration.base import BaseTestCase
46

7+
58
sa = 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

Comments
 (0)