def test_prevent_user_became_editor_when_joining_playground(self): user1 = UserFactory() group = PlaygroundGroupFactory(newcomers=[user1]) Notification.objects.all().delete() user = UserFactory() group.add_member(user) self.assertEqual(Notification.objects.count(), 1) you_became_editor = Notification.objects.get( type=NotificationType.YOU_BECAME_EDITOR.value) self.assertEqual(you_became_editor.user, user)
class TestPlaygroundGroupAPI(APITestCase): def setUp(self): self.member = UserFactory() self.group = PlaygroundGroupFactory(members=[self.member], password='') def test_change_password_has_no_effect(self): self.client.force_login(user=self.member) url = reverse('group-detail', kwargs={'pk': self.group.id}) response = self.client.patch(url, data={'public_description': 'buy our nice horse'}) self.assertEqual(response.status_code, status.HTTP_200_OK) self.group.refresh_from_db() self.assertEqual(self.group.password, '')
def test_no_notifications_by_default_in_playground(self): user = UserFactory() group = PlaygroundGroupFactory() membership = group.groupmembership_set.create(user=user) self.assertEqual([], membership.notification_types) conversation = Conversation.objects.get_for_target(group) conversation_participant = ConversationParticipant.objects.get(conversation=conversation, user=user) self.assertTrue(conversation_participant.muted)
class TestGroupPlaygroundReceivers(TestCase): def setUp(self): self.group = PlaygroundGroupFactory() def test_playground_members_are_always_editors(self): new_member = UserFactory() mail.outbox = [] self.group.add_member(new_member) self.assertTrue(self.group.is_editor(new_member)) # no email should be sent when joining playground self.assertEqual(len(mail.outbox), 0) # no email should be sent when giving trust membership = GroupMembership.objects.get(group=self.group, user=new_member) another_user = UserFactory() self.group.add_member(another_user) mail.outbox = [] Trust.objects.create(membership=membership, given_by=another_user) self.assertEqual(len(mail.outbox), 0)
def setUp(self): inactive_user = UserFactory() playground_group = PlaygroundGroupFactory(members=[inactive_user]) inactive_group = InactiveGroupFactory(members=[inactive_user]) set_lastseen_at(playground_group, inactive_user, days=settings.NUMBER_OF_DAYS_UNTIL_INACTIVE_IN_GROUP + 1) set_lastseen_at(inactive_group, inactive_user, days=settings.NUMBER_OF_DAYS_UNTIL_INACTIVE_IN_GROUP + 1) mail.outbox = []
def setUp(self): self.member = UserFactory() self.group = PlaygroundGroupFactory(members=[self.member], password='')
def setUp(self): self.group = PlaygroundGroupFactory()