Пример #1
0
def index():
    slack_message = request.json

    # This will never run if using eventsrouter...
    if slack_message.get("type") == "url_verification":
        return Response(slack_message.get("challenge"), status=200)

    event = slack_message.get("event", {})
    event_type = event.get("type", None)

    if event_type != "file_shared":
        return Response("Unsupported event type", status=401)

    file_id = event.get("file_id", None)

    if not file_id:
        return Response("No file id", status=401)

    try:
        local_file = fetch_slack_file(file_id)
        dataset = Process(local_file)
        dataset.etl()
    except Exception as e:
        notify_error(e)
        return Response("Error", status=500)

    notify_success()
    clear_tmp()
    return Response("OK", status=200)
Пример #2
0
def test_bad_data():
    file_path = os.path.abspath("./test/data/bad.xlsx")
    dataset = Process(file_path)
    try:
        dataset.etl()
    except MismatchedDataSchema:
        assert True
        return
    assert False
Пример #3
0
def test_good_data():
    file_path = os.path.abspath("./test/data/good.xlsx")
    dataset = Process(file_path)
    try:
        dataset.etl()
    except Exception:
        assert False
        return
    assert True