Esempio n. 1
0
 def test_subscribes_without_user(self):
     pubsub_mock = mock.Mock()
     with mock.patch.object(redis, 'pubsub',
                            mock.Mock(return_value=pubsub_mock)):
         client = Client()
     calls = [call[0][0] for call in pubsub_mock.subscribe.call_args_list]
     assert_that(calls, contains_inanyorder(client_channel(client.uuid), ))
Esempio n. 2
0
class TestUtils__notify_notify_client(TestCase):
    def setUp(self):
        super(TestUtils__notify_notify_client, self).setUp()

        self.create_users()
        self.client = Client(self.users[0].id)

    def test_simple(self):
        notify_client(self.client.uuid, message={'test': 123})
        assert_that(self.client.get_message(), equal_to({'test': 123}))
Esempio n. 3
0
class TestUtils__notify_client_get_message(TestCase):
    def setUp(self):
        super(TestUtils__notify_client_get_message, self).setUp()

        self.create_users()
        self.client = Client(user_id=self.users[0].id)

    def test_client_channel(self):
        channel = client_channel(self.client.uuid)
        data = pickle.dumps(123)

        redis.publish(channel, data)
        time.sleep(0.1)
        assert_that(self.client.get_message(), equal_to(123))

    def test_user_channel(self):
        channel = user_channel(self.users[0].id)
        data = pickle.dumps(123)

        redis.publish(channel, data)
        time.sleep(0.1)
        assert_that(self.client.get_message(), equal_to(123))
Esempio n. 4
0
    def setUp(self):
        super(TestUtils__notify_notify_user, self).setUp()

        self.create_users()
        self.client = Client(self.users[0].id)
Esempio n. 5
0
    def setUp(self):
        super(TestUtils__notify_client_get_message, self).setUp()

        self.create_users()
        self.client = Client(user_id=self.users[0].id)