|
@ -66,7 +66,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
def test_it_adds_team_member(self): |
|
|
def test_it_adds_team_member(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "rw": "1"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "w"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
def test_it_adds_readonly_team_member(self): |
|
|
def test_it_adds_readonly_team_member(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
@ -100,6 +100,20 @@ class ProjectTestCase(BaseTestCase): |
|
|
|
|
|
|
|
|
self.assertEqual(member.role, member.Role.READONLY) |
|
|
self.assertEqual(member.role, member.Role.READONLY) |
|
|
|
|
|
|
|
|
|
|
|
def test_it_adds_manager_team_member(self): |
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "m"} |
|
|
|
|
|
r = self.client.post(self.url, form) |
|
|
|
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
|
|
|
|
member = Member.objects.get( |
|
|
|
|
|
project=self.project, user__email="[email protected]" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# The new user should have role manager |
|
|
|
|
|
self.assertEqual(member.role, member.Role.MANAGER) |
|
|
|
|
|
|
|
|
def test_it_adds_member_from_another_team(self): |
|
|
def test_it_adds_member_from_another_team(self): |
|
|
# With team limit at zero, we should not be able to invite any new users |
|
|
# With team limit at zero, we should not be able to invite any new users |
|
|
self.profile.team_limit = 0 |
|
|
self.profile.team_limit = 0 |
|
@ -111,7 +125,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
Member.objects.create(user=self.charlie, project=p2) |
|
|
Member.objects.create(user=self.charlie, project=p2) |
|
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
@ -125,7 +139,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
def test_it_rejects_duplicate_membership(self): |
|
|
def test_it_rejects_duplicate_membership(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertContains(r, "[email protected] is already a member") |
|
|
self.assertContains(r, "[email protected] is already a member") |
|
|
|
|
|
|
|
@ -135,7 +149,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
def test_it_rejects_owner_as_a_member(self): |
|
|
def test_it_rejects_owner_as_a_member(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertContains(r, "[email protected] is already a member") |
|
|
self.assertContains(r, "[email protected] is already a member") |
|
|
|
|
|
|
|
@ -146,7 +160,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
aaa = "a" * 300 |
|
|
aaa = "a" * 300 |
|
|
form = {"invite_team_member": "1", "email": f"frank+{aaa}@example.org"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": f"frank+{aaa}@example.org", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
self.assertEqual(r.status_code, 200) |
|
|
|
|
|
|
|
@ -161,7 +175,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertContains(r, "Too Many Requests") |
|
|
self.assertContains(r, "Too Many Requests") |
|
|
|
|
|
|
|
@ -170,7 +184,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
def test_it_requires_owner_to_add_team_member(self): |
|
|
def test_it_requires_owner_to_add_team_member(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
|
|
|
|
|
@ -180,7 +194,7 @@ class ProjectTestCase(BaseTestCase): |
|
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]", "role": "r"} |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
|
|
|
|
|
@ -200,6 +214,19 @@ class ProjectTestCase(BaseTestCase): |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
self.assertEqual(r.status_code, 403) |
|
|
|
|
|
|
|
|
|
|
|
def test_it_rejects_manager_remove_self(self): |
|
|
|
|
|
self.bobs_membership.role = "m" |
|
|
|
|
|
self.bobs_membership.save() |
|
|
|
|
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|
|
|
|
form = {"remove_team_member": "1", "email": "[email protected]"} |
|
|
|
|
|
r = self.client.post(self.url, form) |
|
|
|
|
|
self.assertEqual(r.status_code, 400) |
|
|
|
|
|
|
|
|
|
|
|
# The number of memberships should have not decreased |
|
|
|
|
|
self.assertEqual(self.project.member_set.count(), 1) |
|
|
|
|
|
|
|
|
def test_it_checks_membership_when_removing_team_member(self): |
|
|
def test_it_checks_membership_when_removing_team_member(self): |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
|