示例#1
0
    def test_primary_coordinates(self):
        extractor = _instantiate_extractor('standard_child_file_csv.yaml')
        rows = _get_content_as_csv('standard_child_file.csv')
        first_row = next(iter(rows))

        key = extractor._primary_coordinates(first_row)
        expected_key = IngestFieldCoordinates('sentence_group',
                                              'sentence_group_id', '113377')
        self.assertEqual(expected_key, key)
    def test_primary_coordinates(self) -> None:
        extractor = _instantiate_extractor("standard_child_file_csv.yaml")
        rows = _get_content_as_csv("standard_child_file.csv")
        first_row = next(iter(rows))

        key = extractor._primary_coordinates(first_row)
        expected_key = IngestFieldCoordinates("sentence_group",
                                              "sentence_group_id", "113377")
        self.assertEqual(expected_key, key)
示例#3
0
def _generate_incarceration_period_primary_key(
        _file_tag: str, row: Dict[str, str]) -> IngestFieldCoordinates:
    person_id = row['control_number']
    sentence_group_id = row['inmate_number']
    sequence_number = row['sequence_number']
    incarceration_period_id = f"{person_id}-{sentence_group_id}-{sequence_number}"

    return IngestFieldCoordinates('state_incarceration_period',
                                  'state_incarceration_period_id',
                                  incarceration_period_id)
示例#4
0
def _generate_supervision_period_primary_key(
        _file_tag: str, row: Dict[str, str]) -> IngestFieldCoordinates:
    person_id = row['parole_number']
    parole_count = row['parole_count_id']
    period_sequence_number = row['period_sequence_number']
    supervision_period_id = f"{person_id}-{parole_count}-{period_sequence_number}"

    return IngestFieldCoordinates('state_supervision_period',
                                  'state_supervision_period_id',
                                  supervision_period_id)
示例#5
0
def _generate_supervision_sentence_primary_key(
        _file_tag: str, row: Dict[str, str]) -> IngestFieldCoordinates:
    person_id = row['ParoleNumber']
    parole_count = row['ParoleCountID']
    sentence_group_index = row['Sent16DGroupNumber']
    sentence_id = row.get('SentenceID', 'none')
    supervision_sentence_id = f"{person_id}-{parole_count}-{sentence_group_index}-{sentence_id}"

    return IngestFieldCoordinates('state_supervision_sentence',
                                  'state_supervision_sentence_id',
                                  supervision_sentence_id)
示例#6
0
    def test_primary_coordinates_override(self):
        coordinates = IngestFieldCoordinates('sentence_group',
                                             'sentence_group_id', 'abcdef')

        def _override(_row):
            return coordinates

        extractor = _instantiate_extractor('standard_child_file_csv.yaml',
                                           primary_key_override=_override)
        rows = _get_content_as_csv('standard_child_file.csv')
        first_row = next(iter(rows))

        key = extractor._primary_coordinates(first_row)
        expected_key = coordinates
        self.assertEqual(expected_key, key)
    def test_primary_coordinates_override(self) -> None:
        coordinates = IngestFieldCoordinates("sentence_group",
                                             "sentence_group_id", "abcdef")

        def _override(_context: Any,
                      _row: Dict[str, str]) -> IngestFieldCoordinates:
            return coordinates

        extractor = _instantiate_extractor("standard_child_file_csv.yaml",
                                           primary_key_override=_override)
        rows = _get_content_as_csv("standard_child_file.csv")
        first_row = next(iter(rows))

        key = extractor._primary_coordinates(first_row)
        expected_key = coordinates
        self.assertEqual(expected_key, key)
示例#8
0
 def _override(_row):
     return IngestFieldCoordinates('sentence_group',
                                   'sentence_group_id', 'abcdef')
示例#9
0
def _generate_charge_primary_key(_file_tag: str,
                                 row: Dict[str, str]) -> IngestFieldCoordinates:
    return IngestFieldCoordinates('state_charge', 'state_charge_id', _generate_charge_id(row))
示例#10
0
def _generate_period_primary_key(_file_tag: str,
                                 row: Dict[str, str]) -> IngestFieldCoordinates:
    return IngestFieldCoordinates('state_incarceration_period',
                                  'state_incarceration_period_id',
                                  _generate_period_id(row))
示例#11
0
def _generate_alias_temporary_primary_key(
        _row: Dict[str, str]) -> IngestFieldCoordinates:
    return IngestFieldCoordinates('state_alias', 'state_alias_id',
                                  _TEMPORARY_PRIMARY_ID)
示例#12
0
def _generate_sentence_primary_key(row: Dict[str, str]) \
        -> IngestFieldCoordinates:
    return IngestFieldCoordinates('state_incarceration_sentence',
                                  'state_incarceration_sentence_id',
                                  _generate_sentence_id(row))
 def _override(_context: Any,
               _row: Dict[str, str]) -> IngestFieldCoordinates:
     return IngestFieldCoordinates("sentence_group",
                                   "sentence_group_id", "abcdef")
示例#14
0
 def _override(_row):
     return IngestFieldCoordinates("sentence_group",
                                   "sentence_group_id", "abcdef")