def test_add_owner(self): """add_owner adds user as thread owner""" User = get_user_model() user = User.objects.create_user("Bob", "*****@*****.**", "Pass.123") add_owner(self.thread, user) self.assertTrue(user.sync_unread_private_threads) owner = self.thread.threadparticipant_set.get(is_owner=True) self.assertEqual(user, owner.user)
def test_add_owner(self): """add_owner adds user as thread owner""" User = get_user_model() user = User.objects.create_user( "Bob", "*****@*****.**", "Pass.123") add_owner(self.thread, user) self.assertTrue(user.sync_unread_private_threads) owner = self.thread.threadparticipant_set.get(is_owner=True) self.assertEqual(user, owner.user)
def test_remove_participant(self): """remove_participant removes user from thread""" User = get_user_model() user = User.objects.create_user("Bob", "*****@*****.**", "Pass.123") add_owner(self.thread, user) remove_participant(self.thread, user) with self.assertRaises(ThreadParticipant.DoesNotExist): self.thread.threadparticipant_set.get(user=user) set_user_unread_private_threads_sync(user) self.assertTrue(user.sync_unread_private_threads) db_user = User.objects.get(pk=user.pk) self.assertTrue(db_user.sync_unread_private_threads)
def test_remove_participant(self): """remove_participant removes user from thread""" User = get_user_model() user = User.objects.create_user( "Bob", "*****@*****.**", "Pass.123") add_owner(self.thread, user) remove_participant(self.thread, user) with self.assertRaises(ThreadParticipant.DoesNotExist): self.thread.threadparticipant_set.get(user=user) set_user_unread_private_threads_sync(user) self.assertTrue(user.sync_unread_private_threads) db_user = User.objects.get(pk=user.pk) self.assertTrue(db_user.sync_unread_private_threads)
def save(self, form): add_owner(self.thread, self.user) for user in form.users_cache: add_participant(self.request, self.thread, user)