def respondent_has_completed_survey(context):

    # Complete the survey by phone
    ru_ref = '49900000007'
    business_party = get_party_by_ru_ref(ru_ref)
    ce_id = get_collection_exercise('cb8accda-6118-4d3b-85a3-149e28960c54',
                                    '201801')['id']
    case = get_b_case(ce_id, business_party['id'])
    post_case_event(case['id'], 'COMPLETED_BY_PHONE', 'Completed by phone')
    # Ensure respondent is signed in and navigate to history
    signed_in_respondent(context)
    go_to_history_tab()
Exemplo n.º 2
0
 def _create_respondent():
     collection_exercise_id = get_collection_exercise(
         'cb8accda-6118-4d3b-85a3-149e28960c54', '201801')['id']
     enrolment_code = get_iac_for_collection_exercise(
         collection_exercise_id)
     respondent_party = register_respondent(
         email_address='*****@*****.**',
         first_name='first_name',
         last_name='last_name',
         password='******',
         phone_number='0187654321',
         enrolment_code=enrolment_code)
     verify_user(respondent_party['emailAddress'])
     change_respondent_status(respondent_party['id'])
     return respondent_party['id']
def register_respondent(survey_id,
                        period,
                        username,
                        ru_ref=None,
                        verified=True):
    logger.debug('Registering respondent',
                 survey_id=survey_id,
                 period=period,
                 ru_ref=ru_ref)
    collection_exercise_id = collection_exercise_controller.get_collection_exercise(
        survey_id, period)['id']
    if ru_ref:
        business_party = party_controller.get_party_by_ru_ref(ru_ref)
        b_case = case_controller.get_b_case(collection_exercise_id,
                                            business_party['id'])
        if b_case['iac'] is None or not iac_controller.get_iac(
                b_case['iac'])['active']:
            enrolment_code = case_controller.generate_new_enrolment_code(
                b_case['id'], business_party['id'])
        else:
            enrolment_code = b_case['iac']
    else:
        enrolment_code = database_controller.get_iac_for_collection_exercise(
            collection_exercise_id)
    respondent_party = party_controller.register_respondent(
        email_address=username,
        first_name='first_name',
        last_name='last_name',
        password=Config.RESPONDENT_PASSWORD,
        phone_number='0987654321',
        enrolment_code=enrolment_code)

    respondent_id = respondent_party['id']
    if verified:
        party_controller.change_respondent_status(respondent_party['id'])
    logger.debug('Successfully registered respondent',
                 survey_id=survey_id,
                 period=period,
                 ru_ref=ru_ref,
                 respondent_id=respondent_id)
    return respondent_id
Exemplo n.º 4
0
def poll_database_for_iac(survey_id, period, social=False, count=1):
    logger.info('Waiting for collection exercise execution process to finish',
                survey_id=survey_id,
                period=period)
    collection_exercise_id = collection_exercise_controller.get_collection_exercise(
        survey_id, period)['id']
    attempt = 1
    while attempt <= 20:
        logger.info("Getting iac code for collection exercise",
                    collection_exercise_id=collection_exercise_id,
                    social=social,
                    attempt=attempt)
        iac_code = database_controller.get_iac_for_collection_exercise(
            collection_exercise_id, social=social, count=count)
        if iac_code:
            logger.info('Collection exercise finished executing',
                        survey_id=survey_id,
                        period=period)
            return iac_code
        time.sleep(3)
        attempt += 1
    raise Exception("Failed to get iac code for collection exercise")
Exemplo n.º 5
0
def execute_collection_exercise(survey_id,
                                period,
                                ci_type='SEFT',
                                performance_test=False):
    logger.info('Executing collection exercise',
                survey_id=survey_id,
                period=period,
                ci_type=ci_type)
    collection_exercise = collection_exercise_controller.get_collection_exercise(
        survey_id, period)

    if ci_type == 'eQ':
        collection_instruments = get_collection_instruments_by_classifier(
            survey_id, form_type='0001')
        for collection_instrument in collection_instruments:
            link_collection_instrument_to_exercise(collection_instrument['id'],
                                                   collection_exercise['id'])
    else:
        upload_seft_collection_instrument(
            collection_exercise['id'],
            'resources/collection_instrument_files/064_201803_0001.xlsx',
            form_type='0001')

    sample_filename = 'performance-test-sample.csv' if performance_test else 'resources/sample_files/business-survey-sample-date.csv'
    sample_summary = sample_controller.upload_sample(collection_exercise['id'],
                                                     sample_filename)
    collection_exercise_controller.link_sample_summary_to_collection_exercise(
        collection_exercise['id'], sample_summary['id'])
    poll_collection_exercise_until_state_changed(collection_exercise['id'],
                                                 'READY_FOR_REVIEW')
    collection_exercise_controller.execute_collection_exercise(
        survey_id, period)
    logger.info('Successfully executed collection exercise',
                survey_id=survey_id,
                period=period,
                ci_type=ci_type)
Exemplo n.º 6
0
def enrol_respondent(party_id, survey_id, period):
    collection_exercise_id = collection_exercise_controller.get_collection_exercise(
        survey_id, period)['id']
    enrolment_code = database_controller.get_iac_for_collection_exercise(
        collection_exercise_id)
    party_controller.add_survey(party_id, enrolment_code)
def _get_last_qbs_collection_exercise_id():
    return get_collection_exercise('02b9c366-7397-42f7-942a-76dc5876d86d',
                                   '1809')['id']
def company_does_not_have_trading_as_name(_):
    ce_id = get_collection_exercise('cb8accda-6118-4d3b-85a3-149e28960c54',
                                    '201801')['id']
    _add_survey_for_ru_to_respondent_suppress_exception(
        '*****@*****.**', '49900000008', ce_id)
def company_has_separate_trading_name_s01(_, ru_ref):
    ce_id = get_collection_exercise('cb8accda-6118-4d3b-85a3-149e28960c54',
                                    '201801')['id']
    _add_survey_for_ru_to_respondent_suppress_exception(
        '*****@*****.**', ru_ref, ce_id)