Пример #1
0
def download_files(ctx, open_date, update_date):
    """
    Download report files to DOWNLOAD_PATH folder.

    :param open_date:
        Earliest open date.
    :param update_date:
        Earliest update date.
    """

    open_date = parse_date(open_date)
    update_date = parse_date(update_date)

    report_download = _get_report_download()
    temp_path = DOWNLOAD_PATH
    timestamp = update_date.strftime('%Y%m%d')
    str_open_date = open_date.strftime('%m/%d/%Y')
    str_update_date = update_date.strftime('%m/%d/%Y')
    # Ticket_dump
    print("Downloading Ticket_dump...")
    report_args = {'Date': str_open_date, 'LastUpdate': str_update_date}
    filename = os.path.join(temp_path, f'Ticket_dump_{timestamp}.xml')
    report_download.download_report('My Reports/Ticket_dump_BI',
                                    ReportFormat.XML, filename, report_args)
    # Task_dump
    print("Downloading Task_dump...")
    report_args = {'LastUpdate': str_update_date}
    filename = os.path.join(temp_path, f'Task_dump_{timestamp}.csv')
    report_download.download_report('My Reports/Task_dump_BI',
                                    ReportFormat.CSV, filename, report_args)
    # Call_dump
    print("Downloading Call_dump...")
    report_args = {'LastUpdate': str_update_date}
    filename = os.path.join(temp_path, f'IncomingCall_dump_{timestamp}.csv')
    report_download.download_report('My Reports/IncomingCall_dump_BI',
                                    ReportFormat.CSV, filename, report_args)
    # CSAT
    print("Downloading CSAT...")
    filename = os.path.join(temp_path, 'CSAT.xml')
    report_download.download_report('My Reports/CSAT', ReportFormat.XML,
                                    filename)

    # CSAT_sent
    print("Downloading CSAT_sent...")
    filename = os.path.join(temp_path, 'CSAT_sent.csv')
    report_download.download_report('My Reports/CSAT_sent', ReportFormat.CSV,
                                    filename)

    # Exluded CSAT
    print("Downloading CSAT_excluded...")
    filename = os.path.join(temp_path, 'Tickets_Excluidos.xml')
    report_download.download_report('Dashboard/Tickets_Excluidos',
                                    ReportFormat.XML, filename)
Пример #2
0
def _weekly_download(ctx, open_date="01/01/2017"):
    parsed_date = parse_date(open_date)
    download_files(ctx, open_date=parsed_date, update_date=parsed_date)
Пример #3
0
def test_parse_date_fail():

    with pytest.raises(Exception):
        parse_date(7)
Пример #4
0
def _daily_download(ctx, open_date="01/01/2017"):
    parsed_date = parse_date(open_date)
    yesterday = datetime.combine(date.today(), time.min) - timedelta(days=1)
    download_files(ctx, open_date=parsed_date, update_date=yesterday)
Пример #5
0
def test_parse_date(newdate):
    expected = datetime(2017, 10, 1, 0, 0)
    parsed_date = parse_date(newdate)

    assert parsed_date == expected