Пример #1
0
    def test_receive_activity_changes(self):
        client = self.connect_as(self.member)

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

        response = client.messages_by_topic.get('activities:activity')[0]
        self.assertEqual(parse(response['payload']['date'][0]), date.start)

        # join
        client = self.connect_as(self.member)
        self.activity.add_participant(self.member)

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

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

        # leave
        client = self.connect_as(self.member)
        self.activity.remove_participant(self.member)

        response = client.messages_by_topic.get('activities:activity')[0]
        self.assertEqual(response['payload']['participants'], [])

        self.assertIn('conversations:leave', client.messages_by_topic.keys())
Пример #2
0
    def test_receive_pickup_changes(self):
        self.client = self.connect_as(self.member)

        # change property
        date = to_range(
            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'][0]), date.start)

        # 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']['collectors'], [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']['collectors'], [])

        self.assertIn('conversations:leave',
                      self.client.messages_by_topic.keys())
Пример #3
0
    def test_receive_series_changes(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 = client.messages_by_topic.get('activities:series')[0]
        self.assertEqual(parse(response['payload']['start_date']), date)

        self.assertEqual(len(client.messages), 1)