コード例 #1
0
def test_recalculate_petitions(petition):
    petition = PetitionFactory(form_type=constants.UNDERAGED_CONVICTIONS)
    batch = petition.batch
    record = CIPRSRecordFactory(batch=batch,
                                jurisdiction=constants.DISTRICT_COURT,
                                county="DURHAM")
    offense = OffenseFactory(
        disposition_method="PROBATION OTHER",
        ciprs_record=record,
        jurisdiction=constants.DISTRICT_COURT,
    )
    offense_record_ids = []
    for i in range(12):
        offense_record = OffenseRecordFactory(offense=offense,
                                              action="CHARGED")
        petition.offense_records.add(offense_record)
        if len(offense_record_ids) < 5:
            offense_record_ids.append(offense_record.id)
    link_offense_records(petition)
    create_documents(petition)

    assert (petition.offense_records.filter(
        petitionoffenserecord__active=True).count() == 12)
    assert petition.has_attachments()
    recalculate_petitions(petition.id, offense_record_ids)
    assert (petition.offense_records.filter(
        petitionoffenserecord__active=True).count() == 5)
    assert not petition.has_attachments()
コード例 #2
0
def record2(batch):
    yield CIPRSRecordFactory(
        batch=batch,
        label=batch.label,
        jurisdiction=constants.DISTRICT_COURT,
        county=constants.DURHAM_COUNTY,
    )
コード例 #3
0
def test_offense_records_by_jurisdiction(batch, jurisdiction):
    """Offense records helper function should allow filtering by jurisdiction."""
    ciprs_record = CIPRSRecordFactory(jurisdiction=jurisdiction, batch=batch)
    offense = OffenseFactory(
        disposition_method=constants.DISMISSED_DISPOSITION_METHODS[0],
        ciprs_record=ciprs_record,
    )
    offense_record = OffenseRecordFactory(action="CHARGED", offense=offense)
    records = batch.dismissed_offense_records(jurisdiction=jurisdiction)
    assert offense_record in records
コード例 #4
0
def many_offense_records(batch, size):
    for i in range(size):
        record = CIPRSRecordFactory(batch=batch,
                                    jurisdiction=constants.DISTRICT_COURT,
                                    county="DURHAM")
        offense = OffenseFactory(
            disposition_method=dismissed.DISMISSED_DISPOSITION_METHODS[0],
            ciprs_record=record,
            jurisdiction=constants.DISTRICT_COURT,
        )
        OffenseRecordFactory(offense=offense, action="CHARGED")
コード例 #5
0
 def create_new_ciprs_record(file_no):
     ciprs_record = CIPRSRecordFactory(
         batch=batch,
         file_no=file_no,
         jurisdiction=constants.DISTRICT_COURT,
         county="DURHAM")
     offense = OffenseFactory(
         ciprs_record=ciprs_record,
         jurisdiction=constants.DISTRICT_COURT,
         disposition_method=dismissed.DISMISSED_DISPOSITION_METHODS[0],
     )
     offense_record = OffenseRecordFactory(offense=offense)
     return offense_record.id
コード例 #6
0
def record1(batch):
    yield CIPRSRecordFactory(batch=batch,
                             label=batch.label,
                             jurisdiction=constants.DISTRICT_COURT)
コード例 #7
0
def record(data):
    rec = CIPRSRecordFactory(data=data)
    rec.refresh_record_from_data()
    rec.refresh_from_db()
    return rec
コード例 #8
0
def record2(batch):
    yield CIPRSRecordFactory(batch=batch, label=batch.label)