def test_can_view_tasks_tab(self): # Any team member can view tasks. for r in [ROLE_CONTRIBUTOR, ROLE_MANAGER, ROLE_ADMIN, ROLE_OWNER]: with self.role(r): self.assertTrue(can_view_tasks_tab(self.team, self.user)) # Outsiders can't. self.assertFalse(can_view_tasks_tab(self.team, self.outsider))
def test_save_role(self): owner = self.owner member_account = UserFactory(username='******', password='******') member = TeamMemberFactory(team=self.team, user=member_account, role=TeamMember.ROLE_CONTRIBUTOR) tv = self.project_video video_url = reverse("videos:video", args=(tv.video.video_id, )) owner.user.set_password("hey") owner.user.save() self.team.is_visible = False self.team.save() resp = self.client.get(video_url, follow=True) self.assertNotEqual(resp.status_code, 200) self.team.video_policy = Team.VP_MEMBER self.task_assign_policy = 10 self.team.save() self.assertTrue(can_add_video(self.team, member.user)) self.assertTrue(can_add_video_somewhere(self.team, member.user)) self.assertTrue(can_view_tasks_tab(self.team, member.user)) self.assertTrue(can_create_and_edit_subtitles(member.user, tv)) self.assertTrue(can_create_and_edit_translations(member.user, tv)) self.assertFalse(can_view_settings_tab(self.team, member.user)) self.save_role(member, owner, ROLE_ADMIN) self.assertTrue(can_add_video_somewhere(self.team, member.user)) self.assertTrue(can_view_tasks_tab(self.team, member.user)) self.assertTrue(can_create_and_edit_subtitles(member.user, tv)) self.assertTrue(can_create_and_edit_translations(member.user, tv)) self.assertTrue(can_view_settings_tab(self.team, member.user)) self.save_role(member, owner, ROLE_CONTRIBUTOR) self.assertFalse(can_view_settings_tab(self.team, member.user)) self.assertTrue(can_add_video_somewhere(self.team, member.user)) self.assertTrue(can_view_tasks_tab(self.team, member.user)) self.assertTrue(can_create_and_edit_subtitles(member.user, tv)) self.assertTrue(can_create_and_edit_translations(member.user, tv)) self.client.login(username=member.user.username, password="******") resp = self.client.get(video_url, follow=True) self.assertEqual(resp.status_code, 200)