def test_getTopicDetails(mocker, prepareResponse, topic, topic_list, resCode): mocker.patch('confluent_kafka.admin.AdminClient.list_topics', return_value=topic_list) TopicConsumer.getTopicDetails(TopicConsumer, prepareResponse, topic) resMsg = '{"name": "test1", "owner": "", "description": "", "readerAcl": {"enabled": true, "users": []}, "writerAcl": {"enabled": true, "users": []}}' assert resCode == prepareResponse.getResponseCode() assert resMsg == prepareResponse.getResponseMsg()
def test_listAllTopics(mocker, prepareResponse, topic_list, resCode): mocker.patch('confluent_kafka.admin.AdminClient.list_topics', return_value=topic_list) TopicConsumer.listAllTopics(TopicConsumer, prepareResponse) resMsg = '{"topics": [{"topicName": "test1", "owner": "", "txenabled": false}, {"topicName": "test2", "owner": "", "txenabled": false}]}' assert resCode == prepareResponse.getResponseCode() assert resMsg == prepareResponse.getResponseMsg()
def test_getTopics(mocker, prepareResponse, topic_list, resCode): mocker.patch('confluent_kafka.admin.AdminClient.list_topics', return_value=topic_list) TopicConsumer.getTopics(TopicConsumer, prepareResponse) resMsg = '{"topics": ["test1", "test2"]}' assert resCode == prepareResponse.getResponseCode() assert resMsg == prepareResponse.getResponseMsg()
def listall_topics(): prepareResponse = PrepareResponse() topicConsumer = TopicConsumer() topicConsumer.listAllTopics(prepareResponse) response = app.response_class(response=prepareResponse.getResponseMsg(), status=prepareResponse.getResponseCode(), mimetype='application/json') return response
def topic_details(topic): topic == request.view_args['topic'] prepareResponse = PrepareResponse() topicConsumer = TopicConsumer() topicConsumer.getTopicDetails(prepareResponse, topic) response = app.response_class(response=prepareResponse.getResponseMsg(), status=prepareResponse.getResponseCode(), mimetype='application/json') return response