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), ))
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}))
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))
def setUp(self): super(TestUtils__notify_notify_user, self).setUp() self.create_users() self.client = Client(self.users[0].id)
def setUp(self): super(TestUtils__notify_client_get_message, self).setUp() self.create_users() self.client = Client(user_id=self.users[0].id)