예제 #1
0
    def test_term_id_lists(self, app):
        all_term_ids = set(
            berkeley.reverse_term_ids(include_future_terms=True,
                                      include_legacy_terms=True))
        canvas_integrated_term_ids = set(berkeley.reverse_term_ids())
        future_term_ids = set(berkeley.future_term_ids())
        legacy_term_ids = set(berkeley.legacy_term_ids())
        assert canvas_integrated_term_ids < all_term_ids
        assert berkeley.sis_term_id_for_name(
            app.config['EARLIEST_LEGACY_TERM']) in all_term_ids
        assert berkeley.sis_term_id_for_name(
            app.config['EARLIEST_TERM']) in all_term_ids
        assert berkeley.sis_term_id_for_name(
            app.config['CURRENT_TERM']) in all_term_ids
        assert berkeley.sis_term_id_for_name(
            app.config['FUTURE_TERM']) in all_term_ids

        assert berkeley.current_term_id() in canvas_integrated_term_ids
        assert berkeley.earliest_term_id() in canvas_integrated_term_ids

        assert future_term_ids.isdisjoint(canvas_integrated_term_ids)
        assert future_term_ids < all_term_ids
        assert berkeley.future_term_id() in future_term_ids

        assert legacy_term_ids.isdisjoint(canvas_integrated_term_ids)
        assert legacy_term_ids < all_term_ids
        assert berkeley.earliest_legacy_term_id() in berkeley.legacy_term_ids()
예제 #2
0
def resolve_sql_template_string(template_string, **kwargs):
    """Our DDL template files are simple enough to use standard Python string formatting."""
    s3_prefix = 's3://' + app.config['LOCH_S3_BUCKET'] + '/'
    s3_protected_prefix = 's3://' + app.config['LOCH_S3_PROTECTED_BUCKET'] + '/'
    template_data = {
        'earliest_term_id':
        earliest_term_id(),
        'rds_app_boa_user':
        app.config['RDS_APP_BOA_USER'],
        'rds_dblink_to_redshift':
        app.config['REDSHIFT_DATABASE'] + '_redshift',
        'rds_schema_advising_notes':
        app.config['RDS_SCHEMA_ADVISING_NOTES'],
        'rds_schema_advisor':
        app.config['RDS_SCHEMA_ADVISOR'],
        'rds_schema_asc':
        app.config['RDS_SCHEMA_ASC'],
        'rds_schema_boac':
        app.config['RDS_SCHEMA_BOAC'],
        'rds_schema_coe':
        app.config['RDS_SCHEMA_COE'],
        'rds_schema_data_science':
        app.config['RDS_SCHEMA_DATA_SCIENCE'],
        'rds_schema_e_i':
        app.config['RDS_SCHEMA_E_I'],
        'rds_schema_oua':
        app.config['RDS_SCHEMA_OUA'],
        'rds_schema_metadata':
        app.config['RDS_SCHEMA_METADATA'],
        'rds_schema_sis_advising_notes':
        app.config['RDS_SCHEMA_SIS_ADVISING_NOTES'],
        'rds_schema_sis_internal':
        app.config['RDS_SCHEMA_SIS_INTERNAL'],
        'rds_schema_sis_terms':
        app.config['RDS_SCHEMA_SIS_TERMS'],
        'rds_schema_student':
        app.config['RDS_SCHEMA_STUDENT'],
        'rds_schema_undergrads':
        app.config['RDS_SCHEMA_UNDERGRADS'],
        'redshift_app_boa_user':
        app.config['REDSHIFT_APP_BOA_USER'],
        'redshift_dblink_group':
        app.config['REDSHIFT_DBLINK_GROUP'],
        'redshift_dblink_group_diablo':
        app.config['REDSHIFT_DBLINK_GROUP_DIABLO'],
        'redshift_schema_advisee':
        app.config['REDSHIFT_SCHEMA_ADVISEE'],
        'redshift_schema_advisor':
        app.config['REDSHIFT_SCHEMA_ADVISOR'],
        'redshift_schema_advisor_internal':
        app.config['REDSHIFT_SCHEMA_ADVISOR_INTERNAL'],
        'redshift_schema_asc':
        app.config['REDSHIFT_SCHEMA_ASC'],
        'redshift_schema_asc_advising_notes':
        app.config['REDSHIFT_SCHEMA_ASC_ADVISING_NOTES'],
        'redshift_schema_asc_advising_notes_internal':
        app.config['REDSHIFT_SCHEMA_ASC_ADVISING_NOTES_INTERNAL'],
        'redshift_schema_boac':
        app.config['REDSHIFT_SCHEMA_BOAC'],
        'redshift_schema_caliper_analytics':
        app.config['REDSHIFT_SCHEMA_CALIPER'],
        'redshift_schema_calnet':
        app.config['REDSHIFT_SCHEMA_CALNET'],
        'redshift_schema_canvas_api':
        app.config['REDSHIFT_SCHEMA_CANVAS_API'],
        'redshift_schema_canvas':
        app.config['REDSHIFT_SCHEMA_CANVAS'],
        'redshift_schema_coe':
        app.config['REDSHIFT_SCHEMA_COE'],
        'redshift_schema_coe_external':
        app.config['REDSHIFT_SCHEMA_COE_EXTERNAL'],
        'redshift_schema_data_science_advising':
        app.config['REDSHIFT_SCHEMA_DATA_SCIENCE_ADVISING'],
        'redshift_schema_data_science_advising_internal':
        app.config['REDSHIFT_SCHEMA_DATA_SCIENCE_ADVISING_INTERNAL'],
        'redshift_schema_e_i_advising_notes':
        app.config['REDSHIFT_SCHEMA_E_I_ADVISING_NOTES'],
        'redshift_schema_e_i_advising_notes_internal':
        app.config['REDSHIFT_SCHEMA_E_I_ADVISING_NOTES_INTERNAL'],
        'redshift_schema_edw':
        app.config['REDSHIFT_SCHEMA_EDW'],
        'redshift_schema_gradescope':
        app.config['REDSHIFT_SCHEMA_GRADESCOPE'],
        'redshift_schema_intermediate':
        app.config['REDSHIFT_SCHEMA_INTERMEDIATE'],
        'redshift_schema_lrs_external':
        app.config['REDSHIFT_SCHEMA_LRS'],
        'redshift_schema_oua':
        app.config['REDSHIFT_SCHEMA_OUA'],
        'redshift_schema_sis':
        app.config['REDSHIFT_SCHEMA_SIS'],
        'redshift_schema_sis_advising_notes':
        app.config['REDSHIFT_SCHEMA_SIS_ADVISING_NOTES'],
        'redshift_schema_sis_advising_notes_internal':
        app.config['REDSHIFT_SCHEMA_SIS_ADVISING_NOTES_INTERNAL'],
        'redshift_schema_sis_internal':
        app.config['REDSHIFT_SCHEMA_SIS_INTERNAL'],
        'redshift_schema_sis_terms':
        app.config['REDSHIFT_SCHEMA_SIS_TERMS'],
        'redshift_schema_student':
        app.config['REDSHIFT_SCHEMA_STUDENT'],
        'redshift_schema_undergrads':
        app.config['REDSHIFT_SCHEMA_UNDERGRADS'],
        'redshift_schema_undergrads_external':
        app.config['REDSHIFT_SCHEMA_UNDERGRADS_EXTERNAL'],
        'redshift_iam_role':
        app.config['REDSHIFT_IAM_ROLE'],
        'loch_s3_asc_data_path':
        s3_prefix + get_s3_asc_daily_path(),
        'loch_s3_boac_analytics_incremental_path':
        s3_prefix + get_s3_boac_analytics_incremental_path(),
        'loch_s3_calnet_data_path':
        s3_prefix + get_s3_calnet_daily_path(),
        'loch_s3_canvas_api_data_path':
        s3_prefix + get_s3_canvas_api_path(),
        'loch_s3_canvas_data_path_today':
        s3_prefix + get_s3_canvas_daily_path(),
        'loch_s3_canvas_data_path_historical':
        s3_prefix + app.config['LOCH_S3_CANVAS_DATA_PATH_HISTORICAL'],
        'loch_s3_coe_data_path':
        s3_prefix + get_s3_coe_daily_path(),
        'loch_s3_dsa_data_path':
        s3_protected_prefix + app.config['LOCH_S3_DSA_DATA_PATH'],
        'loch_s3_gradescope_data_path':
        s3_prefix + app.config['LOCH_S3_GRADESCOPE_DATA_PATH'],
        'loch_s3_oua_data_path':
        s3_protected_prefix + get_s3_oua_daily_path(),
        'loch_s3_slate_sftp_path':
        s3_protected_prefix + app.config['LOCH_S3_SLATE_DATA_SFTP_PATH'],
        'loch_s3_sis_data_path':
        s3_prefix + app.config['LOCH_S3_SIS_DATA_PATH'],
        'loch_s3_sis_api_data_path':
        s3_prefix + get_s3_sis_api_daily_path(),
        'loch_s3_sis_data_protected_path':
        s3_protected_prefix + app.config['LOCH_S3_SIS_DATA_PATH'],
    }
    # Kwargs may be passed in to modify default template data.
    template_data.update(kwargs)
    return template_string.format(**template_data)