def test_poll_with_content_bindings(): register_uri(POLL_URI, POLL_RESPONSE) client = create_client_10() gen = client.poll(POLL_FEED, uri=POLL_PATH, content_bindings=[CONTENT_BINDING]) block_1 = next(gen) print(gen, block_1.content, CONTENT_BLOCKS) assert block_1.content.decode('utf-8') == CONTENT_BLOCKS[0] message = get_sent_message() assert type(message) == tm10.PollRequest assert message.feed_name == POLL_FEED assert len(message.content_bindings) == 1 assert message.content_bindings[0] == CONTENT_BINDING binding = entities.ContentBinding(CONTENT_BINDING, subtypes=['substype-a']) gen = client.poll(POLL_FEED, uri=POLL_PATH, content_bindings=[binding]) block_1 = next(gen) assert block_1.content.decode('utf-8') == CONTENT_BLOCKS[0] message = get_sent_message() assert type(message) == tm10.PollRequest assert len(message.content_bindings) == 1 assert message.content_bindings[0] == binding.id
def test_poll_with_content_bindings(): register_uri(POLL_URI, POLL_RESPONSE_WITH_MORE_1) client = create_client_11() gen = client.poll(POLL_COLLECTION, uri=POLL_PATH, content_bindings=[CONTENT_BINDING]) block_1 = next(gen) assert block_1.content.decode("utf-8") == CONTENT_BLOCKS[0] message = get_sent_message() assert type(message) == tm11.PollRequest assert message.collection_name == POLL_COLLECTION poll_params = message.poll_parameters assert len(poll_params.content_bindings) == 1 assert poll_params.content_bindings[0].binding_id == CONTENT_BINDING subtypes = ["some-subtype-a", "some-subtype-b"] binding = entities.ContentBinding(CONTENT_BINDING, subtypes=subtypes) gen = client.poll(POLL_COLLECTION, uri=POLL_PATH, content_bindings=[binding]) block_1 = next(gen) assert block_1.content.decode("utf-8") == CONTENT_BLOCKS[0] message = get_sent_message() assert type(message) == tm11.PollRequest poll_params = message.poll_parameters assert len(poll_params.content_bindings) == 1 assert poll_params.content_bindings[0].binding_id == binding.id assert poll_params.content_bindings[0].subtype_ids == binding.subtypes
import pytest from cabby import entities @pytest.mark.parametrize('obj, expected', [ ( entities.ContentBlockCount(count=10, is_partial=False), 'ContentBlockCount(count=10, is_partial=False)', ), ( entities.Collection(name='test', description='not today'), 'Collection(name=test, type=DATA_FEED, available=None)', ), ( entities.ContentBinding(id=17), 'ContentBinding(id=17, subtypes=[])', ), ( entities.ServiceInstance( protocol='http', address='eiq', message_bindings=[], ), 'ServiceInstance(protocol=http, address=eiq)', ), ( entities.InboxService( protocol='http', address='eiq', message_bindings=[],
from cabby import entities @pytest.mark.parametrize( "obj, expected", [ ( entities.ContentBlockCount(count=10, is_partial=False), "ContentBlockCount(count=10, is_partial=False)", ), ( entities.Collection(name="test", description="not today"), "Collection(name=test, type=DATA_FEED, available=None)", ), (entities.ContentBinding(id=17), "ContentBinding(id=17, subtypes=[])"), ( entities.ServiceInstance( protocol="http", address="eiq", message_bindings=[]), "ServiceInstance(protocol=http, address=eiq)", ), ( entities.InboxService( protocol="http", address="eiq", message_bindings=[]), "InboxService(protocol=http, address=eiq)", ), ( entities.PushMethod(protocol="http", message_bindings=[]), "PushMethod(protocol=http)", ), (