コード例 #1
0
 def __init__(self):
     self.publish_service = PublishService()
     with open("resources/dis_config.yml", 'r') as ymlfile:
         cfg = yaml.load(ymlfile)
     PROJ_ENV = cfg['proj_env']
     self.publish_wait_timeout = cfg[PROJ_ENV]['publish_wait_timeout']
     logger.debug('Publish wait timeout - %d', self.publish_wait_timeout)
コード例 #2
0
class DISService(object):

    def __init__(self):
        self.publish_service = PublishService()
        with open("resources/dis_config.yml", 'r') as ymlfile:
            cfg = yaml.load(ymlfile)
        PROJ_ENV = cfg['proj_env']
        self.publish_wait_timeout = cfg[PROJ_ENV]['publish_wait_timeout']
        logger.debug('Publish wait timeout - %d', self.publish_wait_timeout)

    def dispatch(self, banter_message):
        send_status = False
        if banter_message:
            send_status = self.publish_service.publish_message(banter_message)
            if not send_status:
                time.sleep(self.publish_wait_timeout)
                send_status = self.publish_service.publish_message(banter_message)
        return send_status
コード例 #3
0
 def test_publish_message_with_null_publish_instance(self, mock_publish_message):
     mock_publish_message.return_value = False
     publishService = PublishService()
     assert publishService.publish_message(self.banterMessage) == False
コード例 #4
0
 def test_publish_message(self, mock_get_instance):
     mock_get_instance.return_value = PpsPubService()
     publishService = PublishService()
     assert publishService.publish_message(self.banterMessage) == True
コード例 #5
0
 def test_get_instance_with_other_string(self):
     publishService = PublishService()
     assert publishService.get_instance('localpubsub') is None
コード例 #6
0
 def test_get_instance_with_Pypubsub_string(self):
     publishService = PublishService()
     assert publishService.get_instance('Pypubsub') is None
コード例 #7
0
 def test_get_instance_with_pypubsub_string(self):
     publishService = PublishService()
     assert isinstance(publishService.get_instance('pypubsub'), PpsPubService)
コード例 #8
0
 def test_get_instance_with_null_string(self):
     publishService = PublishService()
     assert publishService.get_instance('') is None