コード例 #1
0
def test_log_decode():
    message = '<log><application_name>kassa</application_name><timestamp>2020-04-30T16:42:57+00:00</timestamp><message>test</message></log>'
    log = decode_message(message)
    assert isinstance(log, LogMessage)
    assert log.source_application == 'kassa'
    assert log.timestamp == '2020-04-30T16:42:57+00:00'
    assert log.message == 'test'
コード例 #2
0
def test_error_decode():
    message = '<error><application_name>kassa</application_name><timestamp>2020-04-30T16:42:57+00:00</timestamp><message>test</message></error>'
    error = decode_message(message)
    assert isinstance(error, Error)
    assert error.source_application == 'kassa'
    assert error.timestamp == '2020-04-30T16:42:57+00:00'
    assert error.message == 'test'
コード例 #3
0
async def process_message(message, monitor):
    utf8 = message.body.decode('utf-8')
    LOGGER.info(f'Message incoming from queue: \'{utf8}\'')

    model = decode_message(utf8)
    LOGGER.info(f'Decoded XML message into {model.__class__.__name__}')

    if not isinstance(model, Heartbeat):
        LOGGER.info(f'Persisting {model.__class__.__name__} to ElasticSearch')
        await model.persist()
    else:
        LOGGER.info(f'Processing Heartbeat with monitor')
        status_change = monitor.process_heartbeat(model)

        if status_change:
            LOGGER.info(f'Persisting StatusChange to ElasticSearch: {status_change.application_name} -> online: {status_change.online}')
            await status_change.persist()
コード例 #4
0
def test_event_updateinvoice_decode():
    message = '<update_invoice><application_name>kassa</application_name><invoice_id>test</invoice_id><name>test</name><description>test</description><quantity>test</quantity><price>test</price><paid>test</paid></update_invoice>'
    event = decode_message(message)
    assert isinstance(event, Event)
    assert event.event_type == 'update_invoice'
    assert event.source_application == 'kassa'
コード例 #5
0
def test_event_addinvoice_decode():
    message = '<add_invoice><application_name>kassa</application_name><uuid>test</uuid><paid>test</paid><invoice_date>test</invoice_date><order_line><name>test</name><quantity>test</quantity><price>test</price><discount>test</discount></order_line></add_invoice>'
    event = decode_message(message)
    assert isinstance(event, Event)
    assert event.event_type == 'add_invoice'
    assert event.source_application == 'kassa'
コード例 #6
0
def test_event_patchuser_decode():
    message = '<patch_user><application_name>kassa</application_name><name>test</name><uuid>test</uuid><email>test</email><street>test</street><municipal>test</municipal><postalCode>test</postalCode><vat>test</vat></patch_user>'
    event = decode_message(message)
    assert isinstance(event, Event)
    assert event.event_type == 'patch_user'
    assert event.source_application == 'kassa'
コード例 #7
0
def test_heartbeat_decode():
    message = '<heartbeat><application_name>kassa</application_name><timestamp>2020-04-30T16:42:57+00:00</timestamp></heartbeat>'
    heartbeat = decode_message(message)
    assert isinstance(heartbeat, Heartbeat)
    assert heartbeat.source_application == 'kassa'