def test_get_channels(user1, channel1): class MockUser(object): def __init__(self, user_id): self.id = user_id Message.put_item(**dict(channel=channel1, published_at=time.time(), type="text", writer=user1, message="hi")) with AuthenticatedClient(user1) as client_sock: client_sock.sendobj(dict(method='get_channels')) response = client_sock.recvobj() assert response['method'] == u'get_channels' assert 'users' in response assert 'channels' in response channel_names = [ channel['channel'] for channel in response['channels'] ] assert channel1 in channel_names activated_channels = TestChatProtocol.get_activated_channels( MockUser(user1)) assert set(activated_channels) == set(channel_names)
def test_unread_specific_channel(channel1, user1, user2): Message.put_item(channel=channel1, type=u"text", message=u"Text Message", writer=user1, published_at=time.time()) with AuthenticatedClient(user2) as client_sock: client_sock.sendobj(dict(method="unread", channel=channel1)) response = client_sock.recvobj() assert response["method"] == u"unread" new_messages = response["messages"] assert len(new_messages) == 1 assert new_messages[0]["message"] == u"Text Message"
def test_unread_specific_channel(channel1, user1, user2): Message.put_item(channel=channel1, type=u'text', message=u'Text Message', writer=user1, published_at=time.time()) with AuthenticatedClient(user2) as client_sock: client_sock.sendobj(dict(method='unread', channel=channel1)) response = client_sock.recvobj() assert response['method'] == u'unread' new_messages = response['messages'] assert len(new_messages) == 1 assert new_messages[0]['message'] == u'Text Message'
def test_unread_specific_channel(channel1, user1, user2): Message.put_item( channel=channel1, type=u'text', message=u'Text Message', writer=user1, published_at=time.time() ) with AuthenticatedClient(user2) as client_sock: client_sock.sendobj(dict(method='unread', channel=channel1)) response = client_sock.recvobj() assert response['method'] == u'unread' new_messages = response['messages'] assert len(new_messages) == 1 assert new_messages[0]['message'] == u'Text Message'
def test_get_channels(user1, channel1): class MockUser(object): def __init__(self, user_id): self.id = user_id Message.put_item(**dict(channel=channel1, published_at=time.time(), type="text", writer=user1, message="hi")) with AuthenticatedClient(user1) as client_sock: client_sock.sendobj(dict(method='get_channels')) response = client_sock.recvobj() assert response['method'] == u'get_channels' assert 'users' in response assert 'channels' in response channel_names = [channel['channel'] for channel in response['channels']] assert channel1 in channel_names activated_channels = TestChatProtocol.get_activated_channels(MockUser(user1)) assert set(activated_channels) == set(channel_names)