示例#1
0
#
#  SPDX-FileCopyrightText: 2021 Thorsten Hapke [email protected]
#
#  SPDX-License-Identifier: Apache-2.0
#
import gate
from utils.mock_di_api import mock_api
from utils.operator_test import operator_test
        
api = mock_api(__file__)     # class instance of mock_api
mock_api.print_send_msg = False  # set class variable for printing api.send

optest = operator_test(__file__)
# config parameter 


msg = api.Message(attributes={'operator':'di_replication.gate'},body = 'test1')
gate.on_data(msg)
msg = api.Message(attributes={'operator':'di_replication.gate','message.lastBatch':False},body = 'test2')
gate.on_data(msg)
msg = api.Message(attributes={'operator':'di_replication.gate','message.lastBatch':True},body = 'test3')
gate.on_data(msg)


  
#
#  SPDX-FileCopyrightText: 2021 Thorsten Hapke <*****@*****.**>
#
#  SPDX-License-Identifier: Apache-2.0
#

# DI-PYOPERATOR GENERATED - DO NOT CHANGE this line and the following 3 lines (Deleted when uploaded.)
from utils.mock_di_api import mock_api
api = mock_api(__file__)

import copy
from datetime import datetime

operator_name = 'create_test_tables'


def log(log_str, level='info'):
    if level == 'debug':
        api.logger.debug(log_str)
    elif level == 'warning':
        api.logger.warning(log_str)
    elif level == 'error':
        api.logger.error(log_str)
    else:
        api.logger.info(log_str)

    now = datetime.now().strftime('%H:%M:%S')
    api.send('log', '{} | {} | {} | {}'.format(now, level, operator_name,
                                               log_str))