def test_broker_single_register(): broker = Broker() data = { 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID').decode('utf-8') } broker.register(data, 'mix') cache = broker.fetch([], 'mix') assert len(cache) == 1
def test_broker_multiple_register(): broker = Broker() data = [{ 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID1').decode('utf-8') }, { 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID2').decode('utf-8') }, { 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID3').decode('utf-8') }, { 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID4').decode('utf-8') }, { 'pk': hexlify(b'this is a test').decode('utf-8'), 'id': hexlify(b'someID5').decode('utf-8') }] for entry in data: broker.register(entry, 'mix') cache = broker.fetch([], 'mix') assert len(cache) == 5