def test_more_than_ten_year_old_conviction(self):
        charge = ChargeFactory.create(
            disposition=["Convicted", Time.TEN_YEARS_AGO])

        charges_with_summary = ChargesWithSummary(charges=[charge])
        TimeAnalyzer.evaluate(charges_with_summary)

        assert charge.expungement_result.time_eligibility.status is EligibilityStatus.ELIGIBLE
        assert charge.expungement_result.time_eligibility.reason == ""
        assert charge.expungement_result.time_eligibility.date_will_be_eligible is None
    def test_less_than_three_year_rule_conviction(self):
        charge = ChargeFactory.create(
            disposition=["Convicted", Time.LESS_THAN_THREE_YEARS_AGO])

        charges_with_summary = ChargesWithSummary(
            charges=[charge], most_recent_conviction=charge)
        TimeAnalyzer.evaluate(charges_with_summary)

        assert charge.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert (charge.expungement_result.time_eligibility.reason ==
                "Most recent conviction is less than three years old")
        assert charge.expungement_result.time_eligibility.date_will_be_eligible == date.today(
        ) + relativedelta(days=+1)
    def test_time_eligibility_date_is_none_when_type_ineligible(self):
        charge = ChargeFactory.create(
            name="Assault in the first degree",
            statute="163.185",
            level="Felony Class A",
            date=Time.ONE_YEAR_AGO,
            disposition=["Convicted", Time.ONE_YEAR_AGO],
        )

        charges_with_summary = ChargesWithSummary(
            charges=[charge], most_recent_conviction=charge)
        TimeAnalyzer.evaluate(charges_with_summary)

        assert charge.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert (charge.expungement_result.time_eligibility.reason ==
                "Most recent conviction is less than three years old")
        assert charge.expungement_result.time_eligibility.date_will_be_eligible is None
    def test_10_yr_old_conviction_with_3_yr_old_mrc(self):
        ten_yr_charge = ChargeFactory.create(
            disposition=["Convicted", Time.TEN_YEARS_AGO])
        three_yr_mrc = ChargeFactory.create(
            disposition=["Convicted", Time.THREE_YEARS_AGO])

        charges = [ten_yr_charge, three_yr_mrc]
        charges_with_summary = ChargesWithSummary(
            charges=charges, most_recent_conviction=three_yr_mrc)
        TimeAnalyzer.evaluate(charges_with_summary)

        assert ten_yr_charge.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert ten_yr_charge.expungement_result.time_eligibility.reason == "Time-ineligible under 137.225(7)(b)"
        assert (ten_yr_charge.expungement_result.time_eligibility.
                date_will_be_eligible == three_yr_mrc.disposition.date +
                Time.TEN_YEARS)

        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 is None
    def test_10_yr_old_conviction_with_less_than_3_yr_old_mrc(self):
        ten_yr_charge = ChargeFactory.create(
            disposition=["Convicted", Time.TEN_YEARS_AGO])
        less_than_three_yr_mrc = ChargeFactory.create(
            disposition=["Convicted", Time.LESS_THAN_THREE_YEARS_AGO])

        charges_with_summary = ChargesWithSummary(
            charges=[ten_yr_charge, less_than_three_yr_mrc],
            most_recent_conviction=less_than_three_yr_mrc)
        TimeAnalyzer.evaluate(charges_with_summary)

        assert ten_yr_charge.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert ten_yr_charge.expungement_result.time_eligibility.reason == "Time-ineligible under 137.225(7)(b)"
        assert (
            ten_yr_charge.expungement_result.time_eligibility.
            date_will_be_eligible == less_than_three_yr_mrc.disposition.date +
            Time.TEN_YEARS)

        assert less_than_three_yr_mrc.expungement_result.time_eligibility.status is EligibilityStatus.INELIGIBLE
        assert (
            less_than_three_yr_mrc.expungement_result.time_eligibility.reason
            == "Most recent conviction is less than three years old")
        assert less_than_three_yr_mrc.expungement_result.time_eligibility.date_will_be_eligible == date.today(
        ) + relativedelta(days=+1)
 def run_expunger(self, mrc, second_mrc):
     charges_with_summary = ChargesWithSummary(
         charges=[mrc, second_mrc],
         most_recent_conviction=mrc,
         second_most_recent_conviction=second_mrc)
     TimeAnalyzer.evaluate(charges_with_summary)