def test_add_to_existing_invite(self):
        invite1 = mommy.make(Invite, notified=now())
        invite2 = mommy.make(Invite)

        users = [invite1.email, invite2.email]

        self.assertFalse(Invite.objects.filter(
            pk=invite1.pk,
            groups__in=[self.newgroup]
        ).exists())
        self.assertFalse(Invite.objects.filter(
            pk=invite2.pk,
            groups__in=[self.newgroup]
        ).exists())

        invite_users_to_group(users, self.user1.pk, self.newgroup.pk)
        # Since one invite was already notified, the call_count should be 1
        self.assertEqual(self.mockemailinvite.delay.call_count, 1)

        self.assertTrue(Invite.objects.filter(
            pk=invite1.pk,
            groups__in=[self.newgroup]
        ).exists())
        self.assertTrue(Invite.objects.filter(
            pk=invite2.pk,
            groups__in=[self.newgroup]
        ).exists())
Test adding an extra group to an existing invite
dataset/ETHPy150Open ofa/connect/open_connect/groups/tests/test_tasks.py/InviteUsersToGroupTest.test_add_to_existing_invite