Exemple #1
0
 def setUp(self):
     self.client = ReceiveAllWSClient()
     self.member = UserFactory()
     self.group = GroupFactory(members=[self.member])
Exemple #2
0
class InvitationReceiverTests(ChannelTestCase):
    def setUp(self):
        self.client = ReceiveAllWSClient()
        self.member = UserFactory()
        self.group = GroupFactory(members=[self.member])

    def test_receive_invitation_updates(self):
        self.client.force_login(self.member)
        self.client.send_and_consume('websocket.connect', path='/')

        invitation = Invitation.objects.create(email='*****@*****.**',
                                               group=self.group,
                                               invited_by=self.member)

        response = self.client.receive(json=True)
        self.assertEqual(response['topic'], 'invitations:invitation')
        self.assertEqual(response['payload']['email'], invitation.email)

        self.assertIsNone(self.client.receive(json=True))

    def test_receive_invitation_accept(self):
        invitation = Invitation.objects.create(email='*****@*****.**',
                                               group=self.group,
                                               invited_by=self.member)
        user = UserFactory()

        self.client.force_login(self.member)
        self.client.send_and_consume('websocket.connect', path='/')

        id = invitation.id
        invitation.accept(user)

        response = next(r for r in self.client.receive_all(json=True)
                        if r['topic'] == 'invitations:invitation_accept')
        self.assertEqual(response['payload']['id'], id)