def test_public_notifications(self):
        connection_a = TestConnection()
        connection_b = TestConnection()

        connection_a.subscribe('swampdragon-notifications', 'notifications',
                               {})
        connection_b.subscribe('swampdragon-notifications', 'notifications',
                               {})
    def test_realtime_notification(self):
        """
        User A creates a Foo, so should not receive a notification
        User B is online and should receive the notification
        User C is subscribed but currently showing as offline
        """
        connection_a = TestConnection(user=self.user_a)
        connection_b = TestConnection(user=self.user_b)
        connection_c = TestConnection(user=self.user_c)

        connection_a.subscribe('swampdragon-notifications', 'notifications',
                               {})
        connection_b.subscribe('swampdragon-notifications', 'notifications',
                               {})
        connection_c.subscribe('swampdragon-notifications', 'notifications',
                               {})

        # User C drops offline
        user_manager.remove_user(self.user_c.pk)
        foo = Foo.objects.create(name='foo', description='foo object')
        notify_users(User.objects.exclude(pk=self.user_a.pk),
                     foo,
                     notification_type='foo')

        self.assertIsNotNone(connection_b.last_pub)
        self.assertIsNone(connection_a.last_pub)
        self.assertIsNone(connection_c.last_pub)