Skip to content

Commit

Permalink
Fix name of task
Browse files Browse the repository at this point in the history
  • Loading branch information
eodolphi committed Aug 11, 2022
1 parent cfca4e3 commit e4a3232
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
2 changes: 0 additions & 2 deletions bluebottle/time_based/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,6 @@ class CreateRecurringSlotEffect(Effect):
def post_save(self, **kwargs):
start = self.instance.end + timedelta(days=1)

print(f'Creating new slot {start}')

PeriodActivitySlot.objects.create(
activity=self.instance.activity,
start=start,
Expand Down
10 changes: 0 additions & 10 deletions bluebottle/time_based/periodic_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,6 @@ def period_activity_slot_has_no_participants(effect):
class PeriodActivitySlotFinishedTask(ModelPeriodicTask):

def get_queryset(self):

if len(PeriodActivitySlot.objects.all()):
print('finishing slots')
print(
PeriodActivitySlot.objects.filter(
end__lt=timezone.now().date(),
status='running',
activity__status__in=['open', 'full']
)
)
return PeriodActivitySlot.objects.filter(
end__lt=timezone.now().date(),
status='running',
Expand Down
2 changes: 1 addition & 1 deletion bluebottle/time_based/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def time_contribution_tasks():

@periodic_task(
run_every=(crontab(minute='*/15')),
name="time_contribution_tasks",
name="period_activity_slot_tasks",
ignore_result=True
)
def period_activity_slot_tasks():
Expand Down
14 changes: 4 additions & 10 deletions bluebottle/time_based/tests/test_periodic_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
DateSlotParticipantFactory, TeamSlotFactory
)

import logging

logger = logging.getLogger(__name__)


class TimeBasedActivityPeriodicTasksTestCase():

Expand Down Expand Up @@ -576,19 +572,17 @@ def run_task(self, when):
mock_date.today.return_value = when.date()
mock_date.side_effect = lambda *args, **kw: date(*args, **kw)

with mock.patch('bluebottle.time_based.triggers.now') as mock_now:
mock_now.today.return_value = when
mock_now.side_effect = lambda *args, **kw: when

with mock.patch(
'bluebottle.time_based.triggers.now',
return_value=when
):
period_activity_slot_tasks()
time_contribution_tasks()

def test_create_new_slot(self):
self.assertEqual(len(self.activity.slots.all()), 1)

logger.error('Running tasks')
self.run_task(now() + timedelta(days=7))
logger.error('Running tasks again')
self.run_task(now() + timedelta(days=7))
self.assertEqual(len(self.activity.slots.all()), 2)

Expand Down

0 comments on commit e4a3232

Please sign in to comment.