Example #1
0
def test_very_old_needs_more_analysis_mrc_with_single_arrest():
    eligible_charge, ineligible_charge = ChargeFactory.create_ambiguous_charge(
        name="Assault in the third degree",
        statute="163.165",
        level="Felony Class C",
        disposition=DispositionCreator.create(ruling="Convicted", date=Time.TWENTY_YEARS_AGO),
    )
    arrest = ChargeFactory.create(disposition=DispositionCreator.create(ruling="Dismissed", date=Time.THREE_YEARS_AGO))

    case_a = CaseFactory.create(charges=tuple([eligible_charge, arrest]))
    case_b = CaseFactory.create(charges=tuple([ineligible_charge, arrest]))
    record_a = Record(tuple([case_a]))
    record_b = Record(tuple([case_b]))
    expunger_result_a = Expunger.run(record_a)
    expunger_result_b = Expunger.run(record_b)

    three_years_from_mrc = eligible_charge.disposition.date + Time.THREE_YEARS
    assert expunger_result_a[arrest.ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
    assert (
        expunger_result_a[arrest.ambiguous_charge_id].reason
        == 'Time eligibility of the arrest matches conviction on the same case (the "friendly" rule)'
    )
    assert expunger_result_a[arrest.ambiguous_charge_id].date_will_be_eligible == three_years_from_mrc

    assert expunger_result_b[arrest.ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
    assert expunger_result_b[arrest.ambiguous_charge_id].reason == "Eligible now"
    assert expunger_result_b[arrest.ambiguous_charge_id].date_will_be_eligible == arrest.disposition.date
Example #2
0
def test_expunger_runs_time_analyzer(record_with_specific_dates):
    record = record_with_specific_dates
    expunger = Expunger(record)
    assert expunger.run()

    assert record.cases[0].charges[
        0].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[0].charges[
        1].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[0].charges[
        2].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE

    assert record.cases[1].charges[
        0].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[1].charges[
        1].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[1].charges[
        2].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE

    assert record.cases[2].charges[
        0].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[2].charges[
        1].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
    assert record.cases[2].charges[
        2].expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
def test_expunger_runs_time_analyzer(record_with_specific_dates):
    record = record_with_specific_dates
    expunger = Expunger(record)
    expunger_result = expunger.run()
    assert len(expunger_result) == 9

    assert expunger_result[record.cases[0].charges[
        0].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[0].charges[
        1].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[0].charges[
        2].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE

    assert expunger_result[record.cases[1].charges[
        0].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[1].charges[
        1].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[1].charges[
        2].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE

    assert expunger_result[record.cases[2].charges[
        0].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[2].charges[
        1].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert expunger_result[record.cases[2].charges[
        2].ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
def test_doubly_eligible_b_felony_gets_normal_eligibility_rule():
    # This charge is both ManufactureDelivery and also a class B felony. ManufactureDelivery classification takes precedence and the B felony time rule does not apply.
    manudel_charges = ChargeFactory.create_ambiguous_charge(
        case_number="1",
        name="Manufacture/Delivery 1",
        statute="4759922b",
        level="Felony Class B",
        date=Time.LESS_THAN_TWENTY_YEARS_AGO,
        disposition=DispositionCreator.create(ruling="Convicted", date=Time.LESS_THAN_TWENTY_YEARS_AGO),
    )
    manudel_type_eligilibility = RecordMerger.merge_type_eligibilities(manudel_charges)

    case_1a = CaseFactory.create(case_number="1", charges=tuple([manudel_charges[0]]))
    case_1b = CaseFactory.create(case_number="1", charges=tuple([manudel_charges[1]]))
    subsequent_charge = ChargeFactory.create(
        case_number="2",
        disposition=DispositionCreator.create(ruling="Convicted", date=Time.TEN_YEARS_AGO),
    )
    case_2 = CaseFactory.create(case_number="2", charges=tuple([subsequent_charge]))

    possible_record_1 = Record(tuple([case_1a, case_2]))
    possible_record_2 = Record(tuple([case_1b, case_2]))
    expunger_result_1 = Expunger.run(possible_record_1)
    expunger_result_2 = Expunger.run(possible_record_2)

    assert manudel_type_eligilibility.status is EligibilityStatus.ELIGIBLE
    assert expunger_result_1[manudel_charges[0].ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
    assert expunger_result_2[manudel_charges[1].ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
Example #5
0
def test_case_with_unrecognized_dispo(record_with_unrecognized_dispo):
    expunger = Expunger(record_with_unrecognized_dispo)
    assert expunger.run()
    assert record_with_unrecognized_dispo.errors[0] == (
        f"""Case {record_with_unrecognized_dispo.cases[0].case_number} has a charge with an unrecognized disposition (Something unrecognized).
This might be an error in the OECI database. Time analysis is ignoring this charge and may be inaccurate for other charges."""
    )
Example #6
0
    def test_all_mrd_case_related_dismissals_are_expungeable(self):
        case_related_dismissal = ChargeFactory.create_dismissed_charge(
            case_number=self.case_1.case_number,
            date=Time.TWO_YEARS_AGO,
            violation_type=self.case_1.violation_type)
        self.case_1.charges.append(case_related_dismissal)

        record = Record([self.case_1])
        expunger = Expunger(record)
        expunger_result = expunger.run()

        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[
            self.recent_dismissal.ambiguous_charge_id].reason == "Eligible now"
        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].date_will_be_eligible == Time.TWO_YEARS_AGO

        assert expunger_result[
            case_related_dismissal.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[case_related_dismissal.
                               ambiguous_charge_id].reason == "Eligible now"
        assert expunger_result[
            case_related_dismissal.
            ambiguous_charge_id].date_will_be_eligible == Time.TWO_YEARS_AGO
Example #7
0
def test_felony_class_b_with_subsequent_conviction():
    case_1 = CaseFactory.create(case_number="1")
    b_felony_charge = create_class_b_felony_charge(case_1,
                                                   Time.TWENTY_YEARS_AGO)
    case_1.charges = [b_felony_charge]
    subsequent_charge = ChargeFactory.create(
        disposition=Disposition(ruling="Convicted", date=Time.TEN_YEARS_AGO))
    case_2 = CaseFactory.create(case_number="2")
    case_2.charges = [subsequent_charge]

    expunger = Expunger(Record([case_1, case_2]))
    expunger_result = expunger.run()

    assert expunger_result[
        b_felony_charge.
        ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    assert (
        expunger_result[b_felony_charge.ambiguous_charge_id].reason ==
        "Never. Class B felony can have no subsequent arrests or convictions (137.225(5)(a)(A)(ii))"
    )
    assert expunger_result[
        b_felony_charge.ambiguous_charge_id].date_will_be_eligible == date.max

    # The Class B felony does not affect eligibility of another charge that is otherwise eligible
    assert expunger_result[
        subsequent_charge.
        ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
    assert subsequent_charge.type_eligibility.status is EligibilityStatus.ELIGIBLE
def test_eligible_mrc_with_single_arrest():
    three_yr_mrc = ChargeFactory.create(
        disposition=Disposition(ruling="Convicted", date=Time.THREE_YEARS_AGO))

    arrest = ChargeFactory.create(
        disposition=Disposition(ruling="Dismissed", date=Time.THREE_YEARS_AGO))

    case = CaseFactory.create()
    case.charges = [three_yr_mrc, arrest]
    record = Record([case])
    expunger = Expunger(record)

    expunger.run()
    assert arrest.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
    assert (
        arrest.expungement_result.time_eligibility.reason ==
        'Time eligibility of the arrest matches conviction on the same case (the "friendly" rule)'
    )
    assert arrest.expungement_result.time_eligibility.date_will_be_eligible == date.today(
    )

    assert three_yr_mrc.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
    assert three_yr_mrc.expungement_result.time_eligibility.reason == ""
    assert three_yr_mrc.expungement_result.time_eligibility.date_will_be_eligible == date.today(
    )
Example #9
0
def build_record() -> Record:
    record_strategy = build_record_strategy(min_cases_size=10,
                                            min_charges_size=1)
    record = record_strategy.example()
    expunger = Expunger(record)
    expunger.run()
    return record
def test_expunger_with_open_case(record_with_open_case):
    errors = record_with_open_case.errors
    expunger = Expunger(record_with_open_case)

    assert len(expunger.run()) == 4
    assert "All charges are ineligible because there is one or more open case" in errors[
        0]
def test_very_old_needs_more_analysis_mrc_with_single_arrest():
    charge_dict = ChargeFactory.default_dict()
    charge_dict["name"] = "Assault in the third degree"
    charge_dict["statute"] = "163.165"
    charge_dict["level"] = "Felony Class C"
    charge_dict["disposition"] = Disposition(ruling="Convicted",
                                             date=Time.TWENTY_YEARS_AGO)
    mrc = ChargeFactory.create(**charge_dict)
    arrest = ChargeFactory.create(
        disposition=Disposition(ruling="Dismissed", date=Time.THREE_YEARS_AGO))

    case = CaseFactory.create()
    case.charges = [mrc, arrest]
    record = Record([case])
    expunger = Expunger(record)
    expunger.run()

    three_years_from_mrc = mrc.disposition.date + Time.THREE_YEARS
    assert arrest.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
    assert arrest.expungement_result.time_eligibility.date_will_be_eligible == three_years_from_mrc
    assert arrest.expungement_result.time_eligibility.date_eligible_without_friendly_rule == Time.THREE_YEARS_AGO
    assert arrest.expungement_result.charge_eligibility.status == ChargeEligibilityStatus.ELIGIBLE_NOW
    assert arrest.expungement_result.charge_eligibility.label == "Eligible"

    assert mrc.expungement_result.type_eligibility.status is EligibilityStatus.NEEDS_MORE_ANALYSIS
    assert mrc.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
    assert mrc.expungement_result.time_eligibility.date_will_be_eligible == three_years_from_mrc
    assert mrc.expungement_result.charge_eligibility.status == ChargeEligibilityStatus.POSSIBLY_ELIGIBILE
    assert mrc.expungement_result.charge_eligibility.label == "Possibly Eligible (review)"
def test_probation_revoked_affects_time_eligibility(
        record_with_revoked_probation):
    record = record_with_revoked_probation
    expunger = Expunger(record)
    assert expunger.run()
    assert record.cases[0].charges[
        0].expungement_result.time_eligibility.date_will_be_eligible == date_class(
            2020, 11, 9)
Example #13
0
def test_case_without_dispos(record_without_dispos):
    expunger = Expunger(record_without_dispos)
    assert record_without_dispos.cases[0].closed()
    assert expunger.run()
    assert record_without_dispos.errors[0] == (
        f"""Case {record_without_dispos.cases[0].case_number} has a charge with a missing disposition.
This might be an error in the OECI database. Time analysis is ignoring this charge and may be inaccurate for other charges."""
    )
Example #14
0
    def test_record_with_only_an_mrd_is_time_eligible(self):
        record = Record([self.case_1])
        expunger = Expunger(record)
        expunger.run()

        assert self.recent_dismissal.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
        assert self.recent_dismissal.expungement_result.time_eligibility.reason == ""
        assert self.recent_dismissal.expungement_result.time_eligibility.date_will_be_eligible == Time.TWO_YEARS_AGO
def test_probation_revoked_affects_time_eligibility(
        record_with_revoked_probation):
    record = record_with_revoked_probation
    expunger = Expunger(record)
    expunger_result = expunger.run()
    assert len(expunger_result) == 6
    assert expunger_result[record.cases[0].charges[
        0].ambiguous_charge_id].date_will_be_eligible == date_class(
            2020, 11, 9)
Example #16
0
    def post(self):
        request_data = request.get_json()

        if request_data is None or not request_data.get("names"):
            error(400, "No json data in request body")

        for alias in request_data["names"]:
            check_data_fields(
                alias,
                ["first_name", "last_name", "middle_name", "birth_date"])

        cipher = DataCipher(key=current_app.config.get("SECRET_KEY"))

        if not "oeci_token" in request.cookies.keys():
            error(401, "Missing login credentials to OECI.")

        decrypted_credentials = cipher.decrypt(request.cookies["oeci_token"])

        crawler = Crawler()

        login_result = crawler.login(decrypted_credentials["oeci_username"],
                                     decrypted_credentials["oeci_password"],
                                     close_session=False)

        if login_result is False:
            error(401, "Attempted login to OECI failed")

        cases: List[Case] = []
        for alias in request_data["names"]:
            cases += crawler.search(
                alias["first_name"],
                alias["last_name"],
                alias["middle_name"],
                alias["birth_date"],
            ).cases
        cases_with_unique_case_number = [
            list(group)[0]
            for key, group in groupby(cases, lambda case: case.case_number)
        ]
        record = Record(cases_with_unique_case_number)

        expunger = Expunger(record)
        expunger.run()

        try:
            save_result(request_data, record)
        except Exception as ex:
            logging.error("Saving search result failed with exception: %s" %
                          ex,
                          stack_info=True)

        record_summary = RecordSummarizer.summarize(record)
        response_data = {"data": {"record": record_summary}}

        current_app.json_encoder = ExpungeModelEncoder

        return response_data  # Json-encoding happens automatically here
 def analyze_ambiguous_record(ambiguous_record: AmbiguousRecord):
     charge_id_to_time_eligibilities = []
     for record in ambiguous_record:
         record.errors += ErrorChecker.check(record)  # TODO: Fix mutation
         expunger = Expunger(record)
         charge_id_to_time_eligibility = expunger.run()
         charge_id_to_time_eligibilities.append(
             charge_id_to_time_eligibility)
     record = RecordMerger.merge(ambiguous_record,
                                 charge_id_to_time_eligibilities)
     return record
Example #18
0
    def test_mrd_blocks_dismissals_in_unrelated_cases(self):
        unrelated_dismissal = ChargeFactory.create_dismissed_charge(
            case=self.case_2, date=Time.TEN_YEARS_AGO)
        self.case_2.charges = [unrelated_dismissal]

        record = Record([self.case_1, self.case_2])
        expunger = Expunger(record)
        expunger.run()

        assert unrelated_dismissal.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert unrelated_dismissal.expungement_result.time_eligibility.reason == "Recommend sequential expungement"
        assert unrelated_dismissal.expungement_result.time_eligibility.date_will_be_eligible == Time.ONE_YEARS_FROM_NOW
Example #19
0
    def test_mrd_blocks_dismissals_in_unrelated_cases(self):
        unrelated_dismissal = ChargeFactory.create_dismissed_charge(
            case=self.case_2, date=Time.TEN_YEARS_AGO)
        self.case_2.charges = [unrelated_dismissal]

        record = Record([self.case_1, self.case_2])
        expunger = Expunger(record)
        expunger.run()

        assert unrelated_dismissal.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert (unrelated_dismissal.expungement_result.time_eligibility.reason
                == "Three years from most recent other arrest (137.225(8)(a))")
        assert unrelated_dismissal.expungement_result.time_eligibility.date_will_be_eligible == Time.ONE_YEARS_FROM_NOW
Example #20
0
    def test_record_with_only_an_mrd_is_time_eligible(self):
        record = Record([self.case_1])
        expunger = Expunger(record)
        expunger_result = expunger.run()

        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[
            self.recent_dismissal.ambiguous_charge_id].reason == "Eligible now"
        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].date_will_be_eligible == Time.TWO_YEARS_AGO
Example #21
0
def test_dismissed_felony_class_b_with_subsequent_conviction():
    b_felony_charge = create_class_b_felony_charge(
        Time.LESS_THAN_TWENTY_YEARS_AGO, "Dismissed")
    case_1 = CaseFactory.create()
    case_1.charges = [b_felony_charge]
    subsequent_charge = ChargeFactory.create(
        disposition=Disposition(ruling="Convicted", date=Time.TEN_YEARS_AGO))
    case_2 = CaseFactory.create()
    case_2.charges = [subsequent_charge]

    expunger = Expunger(Record([case_1, case_2]))
    expunger.run()

    assert b_felony_charge.expungement_result.type_eligibility.status is EligibilityStatus.ELIGIBLE
    assert b_felony_charge.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
Example #22
0
def test_case_with_mulitple_disposition_errors(record_with_multiple_disposition_errors):
    expunger = Expunger(record_with_multiple_disposition_errors)
    assert expunger.run()
    unrecognized_error_message = f"""The following cases have charges with an unrecognized disposition.
This might be an error in the OECI database. Time analysis is ignoring these charges and may be inaccurate for other charges.
Case numbers: """
    cases_order_1 = "X0001 (Something unrecognized), X0002 (Something else unrecognized)"
    cases_order_2 = "X0002 (Something else unrecognized), X0001 (Something unrecognized)"
    assert (
        unrecognized_error_message + cases_order_1 in record_with_multiple_disposition_errors.errors
        or unrecognized_error_message + cases_order_2 in record_with_multiple_disposition_errors.errors
    )
    missing_error_message = f"""Case X0003 has a charge with a missing disposition.
This might be an error in the OECI database. Time analysis is ignoring this charge and may be inaccurate for other charges."""
    assert missing_error_message in record_with_multiple_disposition_errors.errors
Example #23
0
    def test_ineligible_mrc_with_arrest_on_single_case(self):
        # In this case, the friendly rule doesn't apply because the conviction doesn't become eligible
        mrc = ChargeFactory.create(
            case_number="1",
            disposition=DispositionCreator.create(
                ruling="Convicted", date=Time.LESS_THAN_THREE_YEARS_AGO),
            statute="666.666",
            level="Felony Class A",
        )

        arrest = ChargeFactory.create(
            case_number="1",
            disposition=DispositionCreator.create(
                ruling="Dismissed", date=Time.LESS_THAN_THREE_YEARS_AGO),
        )
        case = CaseFactory.create(charges=tuple([mrc, arrest]))
        record = Record(tuple([case]))
        expunger_result = Expunger.run(record)

        assert expunger_result[
            arrest.ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (expunger_result[arrest.ambiguous_charge_id].reason ==
                "Ten years from most recent conviction (137.225(7)(b))")
        assert expunger_result[
            mrc.ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (expunger_result[mrc.ambiguous_charge_id].reason ==
                "Never. Type ineligible charges are always time ineligible.")
        assert expunger_result[
            mrc.ambiguous_charge_id].date_will_be_eligible == date.max
Example #24
0
    def test_all_mrd_case_related_dismissals_are_expungeable(self):
        case_related_dismissal = ChargeFactory.create_dismissed_charge(
            case_number=self.case_1.case_number, date=Time.TWO_YEARS_AGO)
        updated_case_1 = replace(
            self.case_1,
            charges=tuple([*self.case_1.charges, case_related_dismissal]))
        record = Record(tuple([updated_case_1]))
        expunger_result = Expunger.run(record)

        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[
            self.recent_dismissal.ambiguous_charge_id].reason == "Eligible now"
        assert expunger_result[
            self.recent_dismissal.
            ambiguous_charge_id].date_will_be_eligible == Time.TWO_YEARS_AGO

        assert expunger_result[
            case_related_dismissal.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[case_related_dismissal.
                               ambiguous_charge_id].reason == "Eligible now"
        assert expunger_result[
            case_related_dismissal.
            ambiguous_charge_id].date_will_be_eligible == Time.TWO_YEARS_AGO
Example #25
0
    def test_10_yr_old_conviction_with_less_than_3_yr_old_mrc(self):
        ten_yr_charge = ChargeFactory.create(
            disposition=DispositionCreator.create(ruling="Convicted",
                                                  date=Time.TEN_YEARS_AGO))
        less_than_three_yr_mrc = ChargeFactory.create(
            disposition=DispositionCreator.create(
                ruling="Convicted", date=Time.LESS_THAN_THREE_YEARS_AGO))
        case = CaseFactory.create(
            charges=tuple([ten_yr_charge, less_than_three_yr_mrc]))
        record = Record(tuple([case]))
        expunger_result = Expunger.run(record)

        assert expunger_result[
            ten_yr_charge.
            ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (expunger_result[ten_yr_charge.ambiguous_charge_id].reason ==
                "Ten years from most recent other conviction (137.225(7)(b))")
        assert (
            expunger_result[ten_yr_charge.ambiguous_charge_id].
            date_will_be_eligible == less_than_three_yr_mrc.disposition.date +
            Time.TEN_YEARS)

        assert expunger_result[
            less_than_three_yr_mrc.
            ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (
            expunger_result[less_than_three_yr_mrc.ambiguous_charge_id].reason
            == "Three years from date of conviction (137.225(1)(a))")
        assert expunger_result[
            less_than_three_yr_mrc.
            ambiguous_charge_id].date_will_be_eligible == date.today(
            ) + relativedelta(days=+1)
Example #26
0
    def test_10_yr_old_conviction_with_3_yr_old_mrc(self):
        ten_yr_charge = ChargeFactory.create(
            disposition=DispositionCreator.create(ruling="Convicted",
                                                  date=Time.TEN_YEARS_AGO))
        three_yr_mrc = ChargeFactory.create(
            disposition=DispositionCreator.create(ruling="Convicted",
                                                  date=Time.THREE_YEARS_AGO))
        case = CaseFactory.create(charges=tuple([ten_yr_charge, three_yr_mrc]))
        record = Record(tuple([case]))
        expunger_result = Expunger.run(record)

        assert expunger_result[
            ten_yr_charge.
            ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (expunger_result[ten_yr_charge.ambiguous_charge_id].reason ==
                "Ten years from most recent other conviction (137.225(7)(b))")
        assert (expunger_result[ten_yr_charge.ambiguous_charge_id].
                date_will_be_eligible == three_yr_mrc.disposition.date +
                Time.TEN_YEARS)

        assert expunger_result[
            three_yr_mrc.
            ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
        assert expunger_result[
            three_yr_mrc.ambiguous_charge_id].reason == "Eligible now"
        assert (expunger_result[three_yr_mrc.ambiguous_charge_id].
                date_will_be_eligible == ten_yr_charge.disposition.date +
                Time.TEN_YEARS)
Example #27
0
def test_felony_class_b_with_prior_conviction():
    b_felony_charge = create_class_b_felony_charge(Time.TWENTY_YEARS_AGO)
    case_1 = CaseFactory.create()
    case_1.charges = [b_felony_charge]
    prior_charge = ChargeFactory.create(disposition=Disposition(
        ruling="Convicted", date=Time.MORE_THAN_TWENTY_YEARS_AGO))
    case_2 = CaseFactory.create()
    case_2.charges = [prior_charge]

    expunger = Expunger(Record([case_1, case_2]))
    expunger.run()

    assert b_felony_charge.expungement_result.type_eligibility.status is EligibilityStatus.NEEDS_MORE_ANALYSIS
    assert b_felony_charge.expungement_result.type_eligibility.reason == "Further Analysis Needed"
    assert b_felony_charge.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
    assert b_felony_charge.expungement_result.time_eligibility.reason == ""
Example #28
0
    def test_all_mrd_case_related_dismissals_are_expungeable(self):
        case_related_dismissal = ChargeFactory.create_dismissed_charge(
            case=self.case_1, date=Time.TWO_YEARS_AGO)
        self.case_1.charges.append(case_related_dismissal)

        record = Record([self.case_1])
        expunger = Expunger(record)
        expunger.run()

        assert self.recent_dismissal.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
        assert self.recent_dismissal.expungement_result.time_eligibility.reason == ""
        assert self.recent_dismissal.expungement_result.time_eligibility.date_will_be_eligible == Time.TWO_YEARS_AGO

        assert case_related_dismissal.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
        assert case_related_dismissal.expungement_result.time_eligibility.reason == ""
        assert case_related_dismissal.expungement_result.time_eligibility.date_will_be_eligible == Time.TWO_YEARS_AGO
def test_marijuana_violation_eligible_with_prior_conviction():
    marijuana_violation = ChargeFactory.create(
        case_number="1",
        name="Possession of Marijuana < 1 Ounce",
        statute="4758643",
        level="Violation Unclassified",
        date=date.today(),
        disposition=DispositionCreator.create(ruling="Convicted", date=date.today() + relativedelta(days=-1)),
    )
    case_1 = CaseFactory.create(case_number="1", charges=tuple([marijuana_violation]))

    prior_conviction = ChargeFactory.create(
        case_number="2",
        name="Identity Theft",
        statute="165.800",
        level="Felony Class C",
        date=Time.FIVE_YEARS_AGO,
        disposition=DispositionCreator.create(ruling="Convicted", date=Time.ONE_YEAR_AGO),
    )
    case_2 = CaseFactory.create(case_number="2", charges=tuple([prior_conviction]))

    expunger_result = Expunger.run(Record(tuple([case_1, case_2])))

    assert isinstance(marijuana_violation.charge_type, MarijuanaViolation)
    assert expunger_result[marijuana_violation.ambiguous_charge_id].status is EligibilityStatus.ELIGIBLE
    assert expunger_result[prior_conviction.ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
    def test_7_yr_old_conviction_2_yr_old_mrc(self):
        seven_year_ago_charge = ChargeFactory.create(
            disposition=DispositionCreator.create(ruling="Convicted", date=Time.SEVEN_YEARS_AGO),
            name="Identity Theft",
            statute="165.800",
            level="Felony Class C",
        )
        two_year_ago_charge = ChargeFactory.create(
            disposition=DispositionCreator.create(ruling="Convicted", date=Time.TWO_YEARS_AGO)
        )

        case = CaseFactory.create(charges=tuple([two_year_ago_charge, seven_year_ago_charge]))
        record = Record(tuple([case]))
        expunger_result = Expunger.run(record)

        assert expunger_result[seven_year_ago_charge.ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (
            expunger_result[seven_year_ago_charge.ambiguous_charge_id].reason
            == f"137.225(7)(b) – Five years from most recent other conviction from case [{case.summary.case_number}]."
        )
        assert (
            expunger_result[seven_year_ago_charge.ambiguous_charge_id].date_will_be_eligible
            == two_year_ago_charge.disposition.date + Time.FIVE_YEARS
        )

        assert expunger_result[two_year_ago_charge.ambiguous_charge_id].status is EligibilityStatus.INELIGIBLE
        assert (
            expunger_result[two_year_ago_charge.ambiguous_charge_id].reason
            == "Three years from date of conviction (137.225(1)(b))"
        )
        assert (
            expunger_result[two_year_ago_charge.ambiguous_charge_id].date_will_be_eligible
            == two_year_ago_charge.disposition.date + Time.THREE_YEARS
        )