-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing petitions when importing form Portal
- Loading branch information
Rebecca Drabenstott
committed
Aug 25, 2024
1 parent
b9ef72d
commit c93535f
Showing
18 changed files
with
191 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 34 additions & 13 deletions
47
dear_petition/petition/types/tests/test_adult_felonies.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
from datetime import datetime | ||
|
||
import pytest | ||
|
||
from dear_petition.petition import constants | ||
from dear_petition.petition.constants import CONVICTED, CHARGED, SEVERITIES | ||
from dear_petition.petition.models import Offense, OffenseRecord | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
def test_adult_felony_included(batch, adult_convicted_guilty_record): | ||
adult_convicted_guilty_record.severity = constants.SEVERITIES.FELONY | ||
adult_convicted_guilty_record.save() | ||
|
||
assert adult_convicted_guilty_record in batch.adult_felony_records() | ||
|
||
|
||
def test_adult_misdemeanor_not_included(batch, adult_convicted_guilty_record): | ||
adult_convicted_guilty_record.severity = constants.SEVERITIES.MISDEMEANOR | ||
adult_convicted_guilty_record.save() | ||
|
||
assert adult_convicted_guilty_record not in batch.adult_felony_records() | ||
@pytest.mark.parametrize( | ||
"action, disposition_method, severity, date, should_be_included", [ | ||
# records that have data as they would from Portal (no action) | ||
("", "District Guilty - Judge", SEVERITIES.FELONY, datetime(2014, 8, 1), True), | ||
("", "District Not Guilty - Judge", SEVERITIES.FELONY, datetime(2014, 8, 1), False), # exclude because not Portal guilty disposition method | ||
("", "District Guilty - Judge", SEVERITIES.MISDEMEANOR, datetime(2014, 8, 1), False), # exclude because misdemeanor severity | ||
("", "District Guilty - Judge", SEVERITIES.FELONY, datetime(2024, 8, 1), False), # exclude because too recent | ||
# records that have data as they would from CIPRS (disposition_method not one seen in Portal) | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.FELONY, datetime(2014, 8, 1), True), | ||
(CHARGED, "Disposed By Judge", SEVERITIES.FELONY, datetime(2014, 8, 1), False), # exclude because not convicted action | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.MISDEMEANOR, datetime(2014, 8, 1), False), # exclude because misdemeanor severity | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.FELONY, datetime(2024, 8, 1), False), # exclude because too recent | ||
] | ||
) | ||
def test_adult_felonies(action, disposition_method, severity, date, should_be_included, batch, record1): | ||
offense = Offense.objects.create( | ||
ciprs_record=record1, | ||
disposition_method=disposition_method, | ||
disposed_on=date, | ||
) | ||
offense_record = OffenseRecord.objects.create( | ||
offense=offense, | ||
action=action, | ||
severity=severity, | ||
) | ||
|
||
if should_be_included: | ||
assert offense_record in batch.adult_felony_records() | ||
else: | ||
assert offense_record not in batch.adult_felony_records() |
47 changes: 34 additions & 13 deletions
47
dear_petition/petition/types/tests/test_adult_misdemeanors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
from datetime import datetime | ||
|
||
import pytest | ||
|
||
from dear_petition.petition import constants | ||
from dear_petition.petition.constants import SEVERITIES, CONVICTED, CHARGED | ||
from dear_petition.petition.models import Offense, OffenseRecord | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
def test_adult_misdemeanor_included(batch, adult_convicted_guilty_record): | ||
adult_convicted_guilty_record.severity = constants.SEVERITIES.MISDEMEANOR | ||
adult_convicted_guilty_record.save() | ||
|
||
assert adult_convicted_guilty_record in batch.adult_misdemeanor_records() | ||
|
||
|
||
def test_adult_felony_not_included(batch, adult_convicted_guilty_record): | ||
adult_convicted_guilty_record.severity = constants.SEVERITIES.FELONY | ||
adult_convicted_guilty_record.save() | ||
|
||
assert adult_convicted_guilty_record not in batch.adult_misdemeanor_records() | ||
@pytest.mark.parametrize( | ||
"action, disposition_method, severity, date, should_be_included", [ | ||
# records that have data as they would from Portal (no action) | ||
("", "District Guilty - Judge", SEVERITIES.MISDEMEANOR, datetime(2019, 8, 1), True), | ||
("", "District Not Guilty - Judge", SEVERITIES.MISDEMEANOR, datetime(2019, 8, 1), False), # exclude because not Portal guilty disposition method | ||
("", "District Guilty - Judge", SEVERITIES.FELONY, datetime(2019, 8, 1), False), # exclude because felony severity | ||
("", "District Guilty - Judge", SEVERITIES.MISDEMEANOR, datetime(2024, 8, 1), False), # exclude because too recent | ||
# records that have data as they would from CIPRS (disposition_method not one seen in Portal) | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.MISDEMEANOR, datetime(2019, 8, 1), True), | ||
(CHARGED, "Disposed By Judge", SEVERITIES.MISDEMEANOR, datetime(2019, 8, 1), False), # exclude because not convicted action | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.FELONY, datetime(2019, 8, 1), False), # exclude because felony severity | ||
(CONVICTED, "Disposed By Judge", SEVERITIES.MISDEMEANOR, datetime(2024, 8, 1), False), # exclude because too recent | ||
] | ||
) | ||
def test_adult_misdemeanors(action, disposition_method, severity, date, should_be_included, batch, record1): | ||
offense = Offense.objects.create( | ||
ciprs_record=record1, | ||
disposition_method=disposition_method, | ||
disposed_on=date, | ||
) | ||
offense_record = OffenseRecord.objects.create( | ||
offense=offense, | ||
action=action, | ||
severity=severity, | ||
) | ||
|
||
if should_be_included: | ||
assert offense_record in batch.adult_misdemeanor_records() | ||
else: | ||
assert offense_record not in batch.adult_misdemeanor_records() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.