コード例 #1
0
def metrics():
    LOGGER.info('Metrics...')
    metrics = {}
    try:
        metrics = to_json(app_context().metrics_service.metrics())
    except:
        e = sys.exc_info()[0]
        LOGGER.exception('Could not get metrics...')
        print(e)
    return response({'body': metrics, 'status_code': '200'})
コード例 #2
0
def get_all():
    LOGGER.debug('Get all data...')
    result = app_context().symptom_service.get()
    return response({
        "status_code":
        '200',
        'body':
        to_json({
            "items": result['items'],
            "total": result['total']
        })
    })
コード例 #3
0
def save():
    LOGGER.info('Adding data...')
    _request = from_json(request.data.decode('utf-8'))
    result = app_context().symptom_service.save(_request)
    return response({
        "status_code":
        '200',
        'body':
        to_json({
            "items": result['items'],
            "total": result['total']
        })
    })
コード例 #4
0
ファイル: app_aws.py プロジェクト: adriandolha/cloud-demo
def get(event, context=None):
    LOGGER.info(f'event = {event}')
    LOGGER.info(f'context={context}')
    query_params = event.get('queryStringParameters')
    id = None
    if query_params is not None and query_params.get('id') is not None:
        id = query_params['id']
    result = app_context().symptom_service.get(id)
    return response({
        "status_code":
        '200',
        'body':
        to_json({
            "items": result['items'],
            "total": result['total']
        })
    })
コード例 #5
0
ファイル: app_aws.py プロジェクト: adriandolha/cloud-demo
def add(event, context=None):
    LOGGER.info(f'event = {event}')
    LOGGER.info(f'context={context}')
    data = app_context().symptom_service.save(from_json(event['body']))
    return response({"status_code": '200', 'body': to_json(data)})
コード例 #6
0
ファイル: conftest.py プロジェクト: adriandolha/cloud-demo
def symptom_valid_request(symptom_valid):
    # from flask import request
    with mock.patch('flask.request'):
        flask.request.data.return_value = to_json(symptom_valid)
        yield ''
コード例 #7
0
 def test_symptom_add(self, symptom_valid, config_valid):
     response = app_aws.add({'body': to_json(symptom_valid)})
     assert not from_json(response['body'])['contact']
     assert '200' == response['statusCode']
コード例 #8
0
 def test_symptom_list_count(self, config_valid):
     response = app_aws.get({'body': to_json({})})
     symptoms = json.loads(response['body'])
     print(symptoms)
     assert symptoms['total']
     assert '200' == response['statusCode']