Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke committed Jan 9, 2024
1 parent 8512308 commit eaaa9c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions backend/benefit/applications/management/commands/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def add_arguments(self, parser):

def handle(self, *args, **options):
batch_count = 6
total_created = ((len(ApplicationStatus.values) * 2) + batch_count) * options[
"number"
statuses = ApplicationStatus.values
filtered_statuses = [
status for status in statuses if status != "rejected_by_talpa"
]
total_created = ((len(filtered_statuses) * 2) + batch_count) * options["number"]
if not settings.DEBUG:
self.stdout.write(
"Seeding is allowed only when the DEBUG variable set to True"
Expand Down Expand Up @@ -128,7 +130,6 @@ def _create_batch(

_create_batch(ApplicationBatchStatus.DECIDED_ACCEPTED, ApplicationStatus.ACCEPTED)
_create_batch(ApplicationBatchStatus.DECIDED_REJECTED, ApplicationStatus.REJECTED)

cancelled_deletion_threshold = _past_datetime(30)
draft_deletion_threshold = _past_datetime(180)
draft_notify_threshold = _past_datetime(180 - 14)
Expand Down
6 changes: 4 additions & 2 deletions backend/benefit/applications/tests/test_application_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
def test_seed_applications_with_arguments(set_debug_to_true):
amount = 5
statuses = ApplicationStatus.values
# exlude rejected_by_talpa status as it is not used in seeder
filtered_statuses = [status for status in statuses if status != "rejected_by_talpa"]
batch_count = 6
total_created = ((len(ApplicationStatus.values) * 2) + batch_count) * amount
total_created = ((len(filtered_statuses) * 2) + batch_count) * amount
out = StringIO()
call_command("seed", number=amount, stdout=out)

seeded_applications = Application.objects.filter(
status__in=statuses,
status__in=filtered_statuses,
)
assert seeded_applications.count() == total_created
assert f"Created {total_created} applications" in out.getvalue()
Expand Down

0 comments on commit eaaa9c6

Please sign in to comment.