Пример #1
0
    def test_receive_pickup_changes(self):
        self.client.force_login(self.member)
        self.client.send_and_consume('websocket.connect', path='/')

        # change property
        date = faker.future_datetime(end_date='+30d', tzinfo=timezone.utc)
        self.pickup.date = date
        self.pickup.save()

        response = self.client.receive(json=True)
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(parse(response['payload']['date']), date)

        # join
        self.pickup.collectors.add(self.member)

        response = self.client.receive(json=True)
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(response['payload']['collector_ids'],
                         [self.member.id])

        # leave
        self.pickup.collectors.remove(self.member)

        response = self.client.receive(json=True)
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(response['payload']['collector_ids'], [])

        self.assertIsNone(self.client.receive(json=True))
Пример #2
0
    def test_receive_pickup_changes(self):
        self.client = self.connect_as(self.member)

        # change property
        date = faker.future_datetime(end_date='+30d', tzinfo=timezone.utc)
        self.pickup.date = date
        self.pickup.save()

        response = self.client.messages_by_topic.get('pickups:pickupdate')[0]
        self.assertEqual(parse(response['payload']['date']), date)

        # join
        self.client = self.connect_as(self.member)
        self.pickup.add_collector(self.member)

        response = self.client.messages_by_topic.get('pickups:pickupdate')[0]
        self.assertEqual(response['payload']['collector_ids'], [self.member.id])

        response = self.client.messages_by_topic.get('conversations:conversation')[0]
        self.assertEqual(response['payload']['participants'], [self.member.id])

        # leave
        self.client = self.connect_as(self.member)
        self.pickup.remove_collector(self.member)

        response = self.client.messages_by_topic.get('pickups:pickupdate')[0]
        self.assertEqual(response['payload']['collector_ids'], [])

        self.assertIn('conversations:leave', self.client.messages_by_topic.keys())
    def test_receive_pickup_changes(self):
        self.client = self.connect_as(self.member)

        # change property
        date = faker.future_datetime(end_date='+30d', tzinfo=timezone.utc)
        self.pickup.date = date
        self.pickup.save()

        response = self.client.messages[0]
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(parse(response['payload']['date']), date)

        # join
        self.pickup.collectors.add(self.member)

        response = self.client.messages[1]
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(response['payload']['collector_ids'], [self.member.id])

        response = self.client.messages[2]
        self.assertEqual(response['topic'], 'conversations:conversation')
        self.assertEqual(response['payload']['participants'], [self.member.id])

        # leave
        self.pickup.collectors.remove(self.member)

        response = self.client.messages[3]
        self.assertEqual(response['topic'], 'pickups:pickupdate')
        self.assertEqual(response['payload']['collector_ids'], [])

        response = self.client.messages[4]
        self.assertEqual(response['topic'], 'conversations:leave')

        self.assertEqual(len(self.client.messages), 5)
Пример #4
0
    def test_receive_series_changes(self):
        self.client = self.connect_as(self.member)

        date = faker.future_datetime(end_date='+30d', tzinfo=timezone.utc) + relativedelta(months=2)
        self.series.start_date = date
        self.series.save()

        response = self.client.messages_by_topic.get('pickups:series')[0]
        self.assertEqual(parse(response['payload']['start_date']), date)

        self.assertEqual(len(self.client.messages), 1)
Пример #5
0
    def test_receive_series_changes(self):
        self.client.force_login(self.member)
        self.client.send_and_consume('websocket.connect', path='/')

        date = faker.future_datetime(end_date='+30d', tzinfo=timezone.utc) + relativedelta(months=2)
        self.series.start_date = date
        self.series.save()

        response = self.client.receive(json=True)
        self.assertEqual(response['topic'], 'pickups:series')
        self.assertEqual(parse(response['payload']['start_date']), date)

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