from expungeservice.models.expungement_result import EligibilityStatus
from expungeservice.models.charge_types.juvenile_charge import JuvenileCharge

from tests.factories.case_factory import CaseSummaryFactory
from tests.factories.charge_factory import ChargeFactory
from tests.models.test_charge import Dispositions


def test_juvenile_charge_dismissed():
    case = CaseSummaryFactory.create(
        type_status=["Juvenile Delinquency: Misdemeanor", "Closed"])
    juvenile_charge = ChargeFactory.create(case_number=case.case_number,
                                           disposition=Dispositions.DISMISSED,
                                           violation_type=case.violation_type)

    assert isinstance(juvenile_charge, JuvenileCharge)
    assert juvenile_charge.type_eligibility.status is EligibilityStatus.NEEDS_MORE_ANALYSIS
    assert juvenile_charge.type_eligibility.reason == "Potentially eligible under 419A.262"


def test_juvenile_charge_convicted():
    case = CaseSummaryFactory.create(
        type_status=["Juvenile Delinquency: Misdemeanor", "Closed"])
    juvenile_charge = ChargeFactory.create(case_number=case.case_number,
                                           disposition=Dispositions.CONVICTED,
                                           violation_type=case.violation_type)

    assert isinstance(juvenile_charge, JuvenileCharge)
    assert juvenile_charge.type_eligibility.status is EligibilityStatus.NEEDS_MORE_ANALYSIS
    assert juvenile_charge.type_eligibility.reason == "Potentially eligible under 419A.262"
class TestBirthYearInitializesGivenMultipleValues(unittest.TestCase):
    def test_birth_year_defaults_to_empty_string(self):
        case = CaseSummaryFactory.create(info=["John Doe"])

        assert case.birth_year is None
Exemple #3
0
from expungeservice.models.charge_types.contempt_of_court import ContemptOfCourt
from expungeservice.models.expungement_result import EligibilityStatus
from tests.factories.charge_factory import ChargeFactory
from tests.factories.case_factory import CaseSummaryFactory
from tests.models.test_charge import Dispositions


def test_contempt_of_court():
    case = CaseSummaryFactory.create(
        type_status=["Contempt of Court", "Closed"])
    charge = ChargeFactory.create(
        case_number=case.case_number,
        name="contempt of court",
        statute="",
        level="N/A",
        disposition=Dispositions.DISMISSED,
        violation_type=case.violation_type,
    )

    assert isinstance(charge.charge_type, ContemptOfCourt)
    assert charge.type_eligibility.status is EligibilityStatus.ELIGIBLE
    assert charge.type_eligibility.reason == "Eligible under 137.225(5)(e) for convictions or under 137.225(1)(b) for dismissals"


def test_contempt_of_court_convicted():
    case = CaseSummaryFactory.create(
        type_status=["Contempt of Court", "Closed"])
    charge = ChargeFactory.create(
        case_number=case.case_number,
        name="contempt of court",
        statute="33065",
        case_2 = CaseCreator.create(*case_args, "2,345.67")  # type: ignore
        assert case_2.get_balance_due() == 2345.67

        case_3 = CaseCreator.create(*case_args, "0")  # type: ignore
        assert case_3.get_balance_due() == 0


class TestCaseClosedMethod(unittest.TestCase):
    def test_it_returns_true_for_a_closed_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Closed"])
        assert case.closed() is True

    def test_it_returns_false_for_an_open_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Open"])
        assert case.closed() is False

    def test_it_returns_true_for_an_inactive_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Inactive"])
        assert case.closed() is True

    def test_it_returns_true_for_a_purged_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Purgable"])
        assert case.closed() is True

    def test_it_returns_true_for_a_bankeruptcy_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Bankruptcy Pending"])
class TestCaseClosedMethod(unittest.TestCase):
    def test_it_returns_true_for_a_closed_case(self):
        case = CaseSummaryFactory.create(
            type_status=["Offense Misdemeanor", "Closed"])
        assert case.closed() is True
        charge_with_disposition = replace(
            charge, disposition=DispositionCreator.create(date=self.THREE_YEARS_AGO, ruling="Dismissed")
        )

        assert charge_with_disposition.recent_dismissal() is False

    def test_convicted_charge_is_not_a_recent_dismissal(self):
        charge = ChargeFactory.create(date=self.LESS_THAN_THREE_YEARS_AGO)
        charge_with_disposition = replace(
            charge, disposition=DispositionCreator.create(date=self.LESS_THAN_THREE_YEARS_AGO, ruling="Convicted")
        )

        assert charge_with_disposition.recent_dismissal() is False

    def test_same_charge_is_not_equal(self):
        case = CaseSummaryFactory.create()
        mrc_charge = ChargeFactory.create(case_number=case.case_number)
        second_mrc_charge = ChargeFactory.create(case_number=case.case_number)

        assert mrc_charge != second_mrc_charge


# TODO: Clean up testing of private methods
class TestChargeStatuteSectionAssignment(unittest.TestCase):
    def test_it_sets_section_to_the_first_6_digits_of_statute(self):
        section = ChargeCreator._set_section("1231235B")
        assert section == "123123"

    def test_it_sets_section_to_the_first_7_digits_when_4th_char_in_statute_is_a_letter(self):
        section = ChargeCreator._set_section(statute="475B3493C")
        assert section == "475B349"
class TestParkingCases(unittest.TestCase):
    def test_open_cases_are_treated_as_closed(self):
        case = CaseSummaryFactory.create(type_status=["Municipal Parking", "Open"])
        assert case.closed() is True
class TestViolationLevelTrafficCases(unittest.TestCase):
    def test_open_cases_are_treated_as_closed(self):
        case = CaseSummaryFactory.create(type_status=["Offense Violation", "Open"])

        assert case.closed() is True
Exemple #9
0
from expungeservice.util import DateWithFuture as date

from expungeservice.models.disposition import DispositionCreator
from expungeservice.models.expungement_result import EligibilityStatus
from expungeservice.models.charge_types.parking_ticket import ParkingTicket

from tests.factories.charge_factory import ChargeFactory
from tests.factories.case_factory import CaseSummaryFactory
from tests.models.test_charge import Dispositions


def test_parking_ticket_conviction():
    case = CaseSummaryFactory.create(
        type_status=["Municipal Parking", "Closed"])
    charge = ChargeFactory.create(
        case_number=case.case_number,
        name="Unknown",
        statute="109",
        level="Violation Unclassified",
        date=date(1901, 1, 1),
        disposition=Dispositions.CONVICTED,
        violation_type=case.violation_type,
    )

    assert isinstance(charge.charge_type, ParkingTicket)
    assert not charge.charge_type.blocks_other_charges
    assert charge.type_eligibility.status is EligibilityStatus.INELIGIBLE
    assert charge.type_eligibility.reason == "Ineligible under 137.225(7)(a)"


def test_parking_ticket_dismissal():
from expungeservice.models.charge_types.misdemeanor_class_bc import MisdemeanorClassBC
from expungeservice.models.charge_types.parking_ticket import ParkingTicket
from expungeservice.models.charge_types.person_felony import PersonFelonyClassB
from expungeservice.models.charge_types.sex_crimes import SexCrime
from expungeservice.models.charge_types.subsection_6 import Subsection6
from expungeservice.models.charge_types.traffic_offense import TrafficOffense
from expungeservice.models.charge_types.traffic_violation import TrafficViolation
from expungeservice.models.charge_types.unclassified_charge import UnclassifiedCharge

from tests.factories.charge_factory import ChargeFactory
from tests.factories.case_factory import CaseSummaryFactory
from tests.models.test_charge import Dispositions


def test_civil_offense_hidden_in_summary():
    case = CaseSummaryFactory.create(type_status=["Civil Offense", "Closed"])
    charge = ChargeFactory.create(
        case_number=case.case_number,
        name="Defamation",
        statute="99",
        level="N/A",
        disposition=Dispositions.CONVICTED,
        violation_type=case.violation_type,
    )

    assert isinstance(charge.charge_type, CivilOffense)
    assert charge.charge_type.hidden_in_record_summary(
        charge.disposition) == False


def test_duii_hidden_in_summary():