Ejemplo n.º 1
0
def test_request_insert():
    """Test comments insertion"""
    summary_data = {
        "tracking_id": '1234567-asdfgh-890123',
        "input": '67890123',
        "input_type": "tac",
        "status": 'PENDING'
    }
    summary_record = Summary.create(summary_data)
    assert summary_record is not None

    request_data = {
        "username": '******',
        "user_id": 'user_id',
        "summary_id": summary_record
    }
    resp = Request.create(request_data)
    assert resp is None

    result = Request.find(request_data['summary_id'], request_data['user_id'])
    assert result is not None
def test_bulk_via_tac_failure(flask_app):
    summary_data = {
        "tracking_id": '1234567-asdfgh-890123',
        "input": '67890222',
        "input_type": "tac",
        "status": 'FAILURE'
    }
    summary_record = Summary.create(summary_data)
    request_data = {
        "username": '******',
        "user_id": 'user_id',
        "summary_id": summary_record
    }
    Request.create(request_data)
    response = flask_app.post('/api/v1/bulk',
                              data=dict(tac='67890222',
                                        indicator='False',
                                        username='******',
                                        user_id='678126378126378'))
    assert response.status_code == 200
    assert response.mimetype == 'application/json'
    assert json.loads(response.get_data(as_text=True))['task_id'] is not None
    assert json.loads(response.get_data(as_text=True))['message'] is not None