def test_everything(driver, profile, base_url, base_api_url):
    do_user_registration(driver, profile, base_url)
    test_ids = get_service_templates_and_api_key_for_tests(driver, profile)

    client = NotificationsAPIClient(
        base_url=base_api_url,
        service_id=test_ids['service_id'],
        api_key=test_ids['api_key']
    )

    upload_csv_page = UploadCsvPage(driver)

    email_notification_id = send_notification_via_csv(profile, upload_csv_page, 'email')
    email_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, email_notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )
    assert_notification_body(email_notification_id, email_notification)

    sms_notification_id = send_notification_via_csv(profile, upload_csv_page, 'sms')
    sms_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, sms_notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )
    assert_notification_body(sms_notification_id, sms_notification)

    do_edit_and_delete_email_template(driver)
    do_user_can_invite_someone_to_notify(driver, profile, base_url)
Exemplo n.º 2
0
def test_admin(driver, client, login_user):
    upload_csv_page = UploadCsvPage(driver)

    csv_sms_notification_id = send_notification_via_csv(upload_csv_page, 'sms')
    csv_sms_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, csv_sms_notification_id, NotificationStatuses.SENT],
        tries=config['notification_retry_times'],
        delay=config['notification_retry_interval'])
    assert_notification_body(csv_sms_notification_id, csv_sms_notification)

    csv_email_notification_id = send_notification_via_csv(
        upload_csv_page, 'email')
    csv_email_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, csv_email_notification_id, NotificationStatuses.SENT],
        tries=config['notification_retry_times'],
        delay=config['notification_retry_interval'])

    assert_notification_body(csv_email_notification_id, csv_email_notification)

    upload_csv_page.sign_out()
def test_admin(driver, base_url, client, profile, login_user):
    upload_csv_page = UploadCsvPage(driver)
    csv_sms_notification_id = send_notification_via_csv(profile, upload_csv_page, 'sms')
    csv_sms_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, csv_sms_notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )
    assert_notification_body(csv_sms_notification_id, csv_sms_notification)

    csv_email_notification_id = send_notification_via_csv(profile, upload_csv_page, 'email')
    csv_email_notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[client, csv_email_notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )

    assert_notification_body(csv_email_notification_id, csv_email_notification)

    upload_csv_page.sign_out()
def test_send_csv(driver, login_seeded_user, seeded_client,
                  seeded_client_using_test_key, message_type):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])

    template_id = {
        'email': config['service']['templates']['email'],
        'sms': config['service']['templates']['sms'],
        'letter': config['service']['templates']['letter'],
    }.get(message_type)

    dashboard_stats_before = get_dashboard_stats(dashboard_page, message_type,
                                                 template_id)

    upload_csv_page = UploadCsvPage(driver)
    notification_id = send_notification_via_csv(upload_csv_page,
                                                message_type,
                                                seeded=True)

    notification = retry_call(get_notification_by_id_via_api,
                              fargs=[
                                  seeded_client_using_test_key if message_type
                                  == 'letter' else seeded_client,
                                  notification_id,
                                  NotificationStatuses.ACCEPTED if message_type
                                  == 'letter' else NotificationStatuses.SENT
                              ],
                              tries=config['notification_retry_times'],
                              delay=config['notification_retry_interval'])
    assert_notification_body(notification_id, notification)

    # test the whole letter creation flow, by checking the PDF has been created
    if message_type == 'letter':
        retry_call(get_pdf_for_letter_via_api,
                   fargs=[seeded_client, notification_id],
                   tries=config['notification_retry_times'],
                   delay=config['notification_retry_interval'])

    dashboard_page.go_to_dashboard_for_service(
        service_id=config['service']['id'])

    dashboard_stats_after = get_dashboard_stats(dashboard_page, message_type,
                                                template_id)

    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)
def test_send_csv(driver, profile, login_seeded_user, seeded_client, message_type):
    dashboard_page = DashboardPage(driver)
    dashboard_page.go_to_dashboard_for_service()
    template_id = profile.email_template_id if message_type == 'email' else profile.sms_template_id

    dashboard_stats_before = get_dashboard_stats(dashboard_page, message_type, template_id)

    upload_csv_page = UploadCsvPage(driver)
    notification_id = send_notification_via_csv(profile, upload_csv_page, message_type, seeded=True)

    notification = retry_call(
        get_notification_by_id_via_api,
        fargs=[seeded_client, notification_id, ['sending', 'delivered']],
        tries=Config.NOTIFICATION_RETRY_TIMES,
        delay=Config.NOTIFICATION_RETRY_INTERVAL
    )
    assert_notification_body(notification_id, notification)
    dashboard_page.go_to_dashboard_for_service()

    dashboard_stats_after = get_dashboard_stats(dashboard_page, message_type, template_id)

    assert_dashboard_stats(dashboard_stats_before, dashboard_stats_after)