Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-karpovich committed May 18, 2022
1 parent 4ba4ad2 commit 1748a0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/etools/applications/partners/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _make_intervention_status_automatic_transitions(country_name):
# we should try all interventions except the ones in terminal statuses
possible_interventions = Intervention.objects.exclude(status__in=[
Intervention.DRAFT, Intervention.TERMINATED, Intervention.CLOSED, Intervention.SUSPENDED
])
]).order_by('id')
processed = 0
for intervention in possible_interventions:
old_status = intervention.status
Expand Down
39 changes: 8 additions & 31 deletions src/etools/applications/partners/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,23 +559,11 @@ def test_make_intervention_status_automatic_transitions_with_valid_interventions
interventions.append(intervention)

# Create a few items that should be ignored. If they're not ignored, this test will fail.
# Ignored because of end date
InterventionFactory(status=Intervention.ACTIVE, end=datetime.date.today() + datetime.timedelta(days=2))
# Ignored because of status
InterventionFactory(status=Intervention.IMPLEMENTED, end=end_date)
# Ignored because funds total outstanding != 0
intervention = InterventionFactory(status=Intervention.ENDED, end=end_date)
for i in range(3):
FundsReservationHeaderFactory(intervention=intervention, outstanding_amt=Decimal(i),
intervention_amt=_make_decimal(i),
actual_amt=_make_decimal(i), total_amt=_make_decimal(i))

# Ignored because funds totals don't match
intervention = InterventionFactory(status=Intervention.ENDED, end=end_date)
for i in range(3):
FundsReservationHeaderFactory(intervention=intervention, outstanding_amt=Decimal(0.00),
intervention_amt=_make_decimal(i),
actual_amt=_make_decimal(i + 1), total_amt=_make_decimal(i))
InterventionFactory(status=Intervention.TERMINATED)
InterventionFactory(status=Intervention.CLOSED)
InterventionFactory(status=Intervention.SUSPENDED)
InterventionFactory(status=Intervention.DRAFT)

# Mock InterventionValid() to always return True.
mock_validator = mock.Mock(spec=['is_valid'])
Expand Down Expand Up @@ -629,22 +617,11 @@ def test_make_intervention_status_automatic_transitions_with_mixed_interventions
interventions.append(intervention)

# Create a few items that should be ignored. If they're not ignored, this test will fail.
# Ignored because of end date
InterventionFactory(status=Intervention.ACTIVE, end=datetime.date.today() + datetime.timedelta(days=2))
# Ignored because of status
InterventionFactory(status=Intervention.IMPLEMENTED, end=end_date)
# Ignored because funds total outstanding != 0
intervention = InterventionFactory(status=Intervention.ENDED, end=end_date)
for i in range(3):
FundsReservationHeaderFactory(intervention=intervention, outstanding_amt=Decimal(i),
intervention_amt=_make_decimal(i),
actual_amt=_make_decimal(i), total_amt=_make_decimal(i))
# Ignored because funds totals don't match
intervention = InterventionFactory(status=Intervention.ENDED, end=end_date)
for i in range(3):
FundsReservationHeaderFactory(intervention=intervention, outstanding_amt=Decimal(0.00),
intervention_amt=_make_decimal(i),
actual_amt=_make_decimal(i + 1), total_amt=_make_decimal(i))
InterventionFactory(status=Intervention.TERMINATED)
InterventionFactory(status=Intervention.CLOSED)
InterventionFactory(status=Intervention.SUSPENDED)
InterventionFactory(status=Intervention.DRAFT)

def mock_intervention_valid_class_side_effect(*args, **kwargs):
"""Side effect for my mock InterventionValid() that gets called each time my mock InterventionValid() class
Expand Down

0 comments on commit 1748a0a

Please sign in to comment.