def test_is_moderated_unset_removess_teams(self): add_moderation(self.video, self.team, self.user) tv,created = TeamVideo.objects.get_or_create(team=self.team, video=self.video) form = EditTeamVideoForm({"is_moderated": False}, None, instance=tv, user=self.user) form.save() self.video = Video.objects.get(pk=self.video.pk) self.assertFalse(self.video.moderated_by)
def test_is_moderated_stores_teams(self): tv,created = TeamVideo.objects.get_or_create(team=self.team, video=self.video) form = EditTeamVideoForm({"is_moderated": True}, None, instance=tv, user=self.user) form.save() self.video = Video.objects.get(pk=self.video.pk) self.assertTrue(self.video.moderated_by) self.assertEquals(self.team, self.video.moderated_by)
def test_only_one_moderator_per_video(self): add_moderation(self.video, self.team, self.user) team , created = Team.objects.get_or_create(slug="a", name="a") tv, created = TeamVideo.objects.get_or_create(video=self.video, team=team, added_by=self.user) form = EditTeamVideoForm(None, None, instance=tv, user=self.user) field = form.fields.get( "is_moderated", False) self.assertFalse(field)
def test_video_moderator_change_in_form(self): add_moderation(self.video, self.team, self.user) self.assertTrue(is_moderated(self.video)) team , created = Team.objects.get_or_create(slug="a", name="a") tv, created = TeamVideo.objects.get_or_create(video=self.video, team=team, added_by=self.user) form = EditTeamVideoForm(None, None, instance=tv, user=self.user) field = form.fields.get( "is_moderated", False) moderating_tv = TeamVideo.objects.get(team=self.team, video=self.video) form = EditTeamVideoForm({"is_moderated":False}, None, instance=moderating_tv, user=self.user) field = form.fields.get( "is_moderated", None) self.assertTrue(field is not None) if form.is_valid(): form.save() self.assertTrue(form.is_valid()) self.video = Video.objects.get(pk=self.video.pk) self.assertFalse(is_moderated(self.video))
def test_is_moderated_exists_on_empty(self): tv,created = TeamVideo.objects.get_or_create(team=self.team, video=self.video) form = EditTeamVideoForm(None, None, instance=tv, user=self.user) field = form.fields.get( "is_moderated", False) self.assertTrue(field) self.assertEquals(field.initial, False)