def test_multiple_topics(self): feed = KafkaChangeFeed(topics=[topics.FORM, topics.CASE], group_id="test-kafka-feed") self.assertEqual(0, len(list(feed.iter_changes(since=None, forever=False)))) producer = KeyedProducer(get_kafka_client_or_none()) offsets = feed.get_current_offsets() send_to_kafka( producer, topics.FORM, ChangeMeta(document_id="1", data_source_type="form", data_source_name="form") ) send_to_kafka( producer, topics.CASE, ChangeMeta(document_id="2", data_source_type="case", data_source_name="case") ) send_to_kafka( producer, topics.FORM_SQL, ChangeMeta(document_id="3", data_source_type="form-sql", data_source_name="form-sql"), ) send_to_kafka( producer, topics.CASE_SQL, ChangeMeta(document_id="4", data_source_type="case-sql", data_source_name="case-sql"), ) changes = list(feed.iter_changes(since=offsets, forever=False)) self.assertEqual(2, len(changes)) self.assertEqual(set(["1", "2"]), set([change.id for change in changes]))
def publish_stub_change(topic): meta = ChangeMeta(document_id=uuid.uuid4().hex, data_source_type='dummy-type', data_source_name='dummy-name') send_to_kafka(_get_producer(), topic, meta) return meta