예제 #1
0
def test_get_all_table_classes():
    aggregate_table_names = [
        'ca_facility_aggregate', 'dc_facility_aggregate',
        'fl_county_aggregate', 'fl_facility_aggregate', 'ga_county_aggregate',
        'hi_facility_aggregate', 'ky_facility_aggregate',
        'ny_facility_aggregate', 'pa_county_pre_sentenced_aggregate',
        'pa_facility_pop_aggregate', 'single_count_aggregate',
        'tn_facility_aggregate', 'tn_facility_female_aggregate',
        'tx_county_aggregate'
    ]
    county_table_names = [
        'arrest', 'arrest_history', 'bond', 'bond_history', 'booking',
        'booking_history', 'charge', 'charge_history', 'hold', 'hold_history',
        'person', 'person_history', 'scraper_success', 'sentence',
        'sentence_history', 'sentence_relationship',
        'sentence_relationship_history'
    ]
    state_table_names = [
        'state_agent',
        'state_agent_history',
        'state_assessment',
        'state_assessment_history',
        'state_bond',
        'state_bond_history',
        'state_charge',
        'state_charge_history',
        'state_court_case',
        'state_court_case_history',
        'state_early_discharge',
        'state_early_discharge_history',
        'state_fine',
        'state_fine_history',
        'state_incarceration_incident',
        'state_incarceration_incident_history',
        'state_incarceration_incident_outcome',
        'state_incarceration_incident_outcome_history',
        'state_incarceration_period',
        'state_incarceration_period_history',
        'state_incarceration_sentence',
        'state_incarceration_sentence_history',
        'state_parole_decision',
        'state_parole_decision_history',
        'state_person',
        'state_person_alias',
        'state_person_alias_history',
        'state_person_ethnicity',
        'state_person_ethnicity_history',
        'state_person_external_id',
        'state_person_external_id_history',
        'state_person_history',
        'state_person_race',
        'state_person_race_history',
        'state_program_assignment',
        'state_program_assignment_history',
        'state_sentence_group',
        'state_sentence_group_history',
        'state_supervision_violated_condition_entry',
        'state_supervision_violated_condition_entry_history',
        'state_supervision_period',
        'state_supervision_period_history',
        'state_supervision_sentence',
        'state_supervision_sentence_history',
        'state_supervision_case_type_entry',
        'state_supervision_case_type_entry_history',
        'state_supervision_contact',
        'state_supervision_contact_history',
        'state_supervision_violation',
        'state_supervision_violation_history',
        'state_supervision_violation_type_entry',
        'state_supervision_violation_type_entry_history',
        'state_supervision_violation_response',
        'state_supervision_violation_response_history',
        'state_supervision_violation_response_decision_entry',
        'state_supervision_violation_response_decision_entry_history',
        'state_charge_fine_association',
        'state_charge_incarceration_sentence_association',
        'state_charge_supervision_sentence_association',
        'state_incarceration_sentence_incarceration_period_association',
        'state_incarceration_sentence_supervision_period_association',
        'state_incarceration_period_program_assignment_association',
        'state_parole_decision_decision_agent_association',
        'state_supervision_period_program_assignment_association',
        'state_supervision_period_supervision_contact_association',
        'state_supervision_sentence_incarceration_period_association',
        'state_supervision_sentence_supervision_period_association',
        'state_supervision_violation_response_decision_agent_association',
        'state_supervision_period_supervision_violation_association',
    ]
    operations_table_names = [
        'direct_ingest_ingest_file_metadata',
        'direct_ingest_raw_file_metadata',
    ]

    expected_table_class_names = \
        aggregate_table_names + county_table_names + state_table_names + operations_table_names

    all_table_classes = get_all_table_classes()

    assert sorted(expected_table_class_names) == \
           sorted(_table_classes_to_qualified_names(all_table_classes))
예제 #2
0
def test_get_all_table_classes():
    aggregate_table_names = [
        "ca_facility_aggregate",
        "dc_facility_aggregate",
        "fl_county_aggregate",
        "fl_facility_aggregate",
        "ga_county_aggregate",
        "hi_facility_aggregate",
        "ky_facility_aggregate",
        "ny_facility_aggregate",
        "pa_county_pre_sentenced_aggregate",
        "pa_facility_pop_aggregate",
        "single_count_aggregate",
        "tn_facility_aggregate",
        "tn_facility_female_aggregate",
        "tx_county_aggregate",
    ]
    county_table_names = [
        "arrest",
        "arrest_history",
        "bond",
        "bond_history",
        "booking",
        "booking_history",
        "charge",
        "charge_history",
        "hold",
        "hold_history",
        "person",
        "person_history",
        "scraper_success",
        "sentence",
        "sentence_history",
        "sentence_relationship",
        "sentence_relationship_history",
    ]
    justice_counts_table_names = [
        "source",
        "report",
        "report_table_definition",
        "report_table_instance",
        "cell",
    ]
    state_table_names = [
        "state_agent",
        "state_agent_history",
        "state_assessment",
        "state_assessment_history",
        "state_bond",
        "state_bond_history",
        "state_charge",
        "state_charge_history",
        "state_court_case",
        "state_court_case_history",
        "state_early_discharge",
        "state_early_discharge_history",
        "state_fine",
        "state_fine_history",
        "state_incarceration_incident",
        "state_incarceration_incident_history",
        "state_incarceration_incident_outcome",
        "state_incarceration_incident_outcome_history",
        "state_incarceration_period",
        "state_incarceration_period_history",
        "state_incarceration_sentence",
        "state_incarceration_sentence_history",
        "state_parole_decision",
        "state_parole_decision_history",
        "state_person",
        "state_person_alias",
        "state_person_alias_history",
        "state_person_ethnicity",
        "state_person_ethnicity_history",
        "state_person_external_id",
        "state_person_external_id_history",
        "state_person_history",
        "state_person_race",
        "state_person_race_history",
        "state_program_assignment",
        "state_program_assignment_history",
        "state_sentence_group",
        "state_sentence_group_history",
        "state_supervision_violated_condition_entry",
        "state_supervision_violated_condition_entry_history",
        "state_supervision_period",
        "state_supervision_period_history",
        "state_supervision_sentence",
        "state_supervision_sentence_history",
        "state_supervision_case_type_entry",
        "state_supervision_case_type_entry_history",
        "state_supervision_contact",
        "state_supervision_contact_history",
        "state_supervision_violation",
        "state_supervision_violation_history",
        "state_supervision_violation_type_entry",
        "state_supervision_violation_type_entry_history",
        "state_supervision_violation_response",
        "state_supervision_violation_response_history",
        "state_supervision_violation_response_decision_entry",
        "state_supervision_violation_response_decision_entry_history",
        "state_charge_fine_association",
        "state_charge_incarceration_sentence_association",
        "state_charge_supervision_sentence_association",
        "state_incarceration_sentence_incarceration_period_association",
        "state_incarceration_sentence_supervision_period_association",
        "state_incarceration_period_program_assignment_association",
        "state_parole_decision_decision_agent_association",
        "state_supervision_period_program_assignment_association",
        "state_supervision_period_supervision_contact_association",
        "state_supervision_sentence_incarceration_period_association",
        "state_supervision_sentence_supervision_period_association",
        "state_supervision_violation_response_decision_agent_association",
        "state_supervision_period_supervision_violation_association",
    ]
    operations_table_names = [
        "direct_ingest_ingest_file_metadata",
        "direct_ingest_raw_file_metadata",
    ]

    expected_table_class_names = (aggregate_table_names + county_table_names +
                                  justice_counts_table_names +
                                  state_table_names + operations_table_names)

    all_table_classes = get_all_table_classes()

    assert sorted(expected_table_class_names) == sorted(
        _table_classes_to_qualified_names(all_table_classes))
예제 #3
0
def test_get_all_table_classes():
    aggregate_table_names = [
        'CaFacilityAggregate',
        'DcFacilityAggregate',
        'FlCountyAggregate',
        'FlFacilityAggregate',
        'GaCountyAggregate',
        'HiFacilityAggregate',
        'KyFacilityAggregate',
        'NyFacilityAggregate',
        'PaCountyPreSentencedAggregate',
        'PaFacilityPopAggregate',
        'SingleCountAggregate',
        'TnFacilityAggregate',
        'TnFacilityFemaleAggregate',
        'TxCountyAggregate',
    ]
    county_table_names = [
        'Arrest',
        'ArrestHistory',
        'Bond',
        'BondHistory',
        'Booking',
        'BookingHistory',
        'Charge',
        'ChargeHistory',
        'Hold',
        'HoldHistory',
        'Person',
        'PersonHistory',
        'Sentence',
        'SentenceHistory',
        'SentenceRelationship',
        'SentenceRelationshipHistory',
    ]
    state_table_names = [
        'StateAgent',
        'StateAgentHistory',
        'StateAssessment',
        'StateAssessmentHistory',
        'StateBond',
        'StateBondHistory',
        'StateCharge',
        'StateChargeHistory',
        'StateCourtCase',
        'StateCourtCaseHistory',
        'StateFine',
        'StateFineHistory',
        'StateIncarcerationIncident',
        'StateIncarcerationIncidentHistory',
        'StateIncarcerationIncidentOutcome',
        'StateIncarcerationIncidentOutcomeHistory',
        'StateIncarcerationPeriod',
        'StateIncarcerationPeriodHistory',
        'StateIncarcerationSentence',
        'StateIncarcerationSentenceHistory',
        'StateParoleDecision',
        'StateParoleDecisionHistory',
        'StatePerson',
        'StatePersonAlias',
        'StatePersonAliasHistory',
        'StatePersonEthnicity',
        'StatePersonEthnicityHistory',
        'StatePersonExternalId',
        'StatePersonExternalIdHistory',
        'StatePersonHistory',
        'StatePersonRace',
        'StatePersonRaceHistory',
        'StateSentenceGroup',
        'StateSentenceGroupHistory',
        'StateSupervisionPeriod',
        'StateSupervisionPeriodHistory',
        'StateSupervisionSentence',
        'StateSupervisionSentenceHistory',
        'StateSupervisionViolation',
        'StateSupervisionViolationHistory',
        'StateSupervisionViolationResponse',
        'StateSupervisionViolationResponseHistory',
    ]

    expected_qualified_names = \
        _prefix_module_name(aggregate_schema.__name__,
                            aggregate_table_names) + \
        _prefix_module_name(county_schema.__name__,
                            county_table_names) + \
        _prefix_module_name(state_schema.__name__,
                            state_table_names)

    assert sorted(_classes_to_qualified_names(
        get_all_table_classes())) == sorted(expected_qualified_names)
예제 #4
0
import sqlalchemy

from recidiviz.persistence.database import schema_utils
from recidiviz.utils import metadata

######### COUNTY EXPORT VALUES #########

COUNTY_TABLES_TO_EXCLUDE_FROM_EXPORT = tuple(  # type: ignore
    # List tables to be excluded from export here. For example:
    # schema.FakePersonHistoryTable
    table.__table__ for table in schema_utils.get_state_table_classes())

# By default, all tables in the various schema.py modules are exported
# unless listed in COUNTY_TABLES_TO_EXCLUDE_FROM_EXPORT above.
COUNTY_TABLES_TO_EXPORT = tuple(
    table.__table__ for table in schema_utils.get_all_table_classes()
    if table.__table__ not in COUNTY_TABLES_TO_EXCLUDE_FROM_EXPORT)

# Mapping from table name to a list of columns to be excluded for that table.
COUNTY_COLUMNS_TO_EXCLUDE = {
    'person': ['full_name', 'birthdate', 'birthdate_inferred_from_age']
}

COUNTY_BASE_TABLES_BQ_DATASET = 'census'

######### STATE EXPORT VALUES #########

# Excluding history tables
STATE_TABLES_TO_EXCLUDE_FROM_EXPORT = tuple(  # type: ignore
    # List tables to be excluded from export here. For example:
    # schema.FakePersonHistoryTable