def test_recently_participated(self): """ Members aren't lapsed if they participated in trips recently. """ # Participant was on a trip in the last year trip = factories.TripFactory.create(trip_date=date(2019, 2, 28)) signup = factories.SignUpFactory.create(trip=trip, on_trip=True) # Override default of 'now' make_last_updated_on(signup.participant, date(1995, 1, 1)) self.assertEqual(len(cleanup.lapsed_participants()), 0) # However, if the trip was too far in the past, we consider them lapsed trip.trip_date = date(2018, 11, 12) # Over 1 year ago trip.save() self.assertEqual(cleanup.lapsed_participants().get(), signup.participant)
def test_not_lapsed_with_recent_update(self): today = date(2019, 12, 25) still_within_window = today - timedelta( days=settings.MUST_UPDATE_AFTER_DAYS - 1 ) factories.ParticipantFactory.create(profile_last_updated=still_within_window) self.assertEqual(len(cleanup.lapsed_participants()), 0)
def test_recently_participated(self): """ Members aren't lapsed if they participated in trips recently. """ # Participant was on a trip in the last year trip = factories.TripFactory.create(trip_date=date(2019, 2, 28)) signup = factories.SignUpFactory.create(participant__membership=None, trip=trip, on_trip=True) # Override default of 'now' make_last_updated_on(signup.participant, date(1995, 1, 1)) self.assertEqual(len(cleanup.lapsed_participants()), 0) # However, if the trip was too far in the past, we consider them lapsed trip.trip_date = date(2018, 11, 12) # Over 1 year ago trip.save() self.assertEqual(cleanup.lapsed_participants().get(), signup.participant)
def test_not_lapsed_with_recent_update(self): today = date(2019, 12, 25) still_within_window = today - timedelta( days=settings.MUST_UPDATE_AFTER_DAYS - 1) factories.ParticipantFactory.create( profile_last_updated=still_within_window) self.assertEqual(len(cleanup.lapsed_participants()), 0)
def test_waiver_current(self): """ Members aren't lapsed if they have a waiver, even with dated profile. """ membership = models.Membership( waiver_expires=date(2020, 1, 1), membership_expires=None, last_cached=date(2019, 12, 1), ) membership.save() participant = factories.ParticipantFactory.create(membership=membership) make_last_updated_on(participant, date(1995, 1, 1)) # Override default of 'now' self.assertEqual(len(cleanup.lapsed_participants()), 0)
def test_lapsed(self): """ Participants are lapsed with expired membership, waiver, and dated profile. """ membership = models.Membership( membership_expires=date(2019, 12, 30), waiver_expires=date(2019, 12, 30), last_cached=date(2019, 12, 30), ) membership.save() participant = factories.ParticipantFactory.create(membership=membership) # Hasn't updated in 13 months make_last_updated_on(participant, date(2012, 12, 1)) self.assertEqual(cleanup.lapsed_participants().get(), participant)
def test_lapsed(self): """ Participants are lapsed with expired membership, waiver, and dated profile. """ membership = models.Membership( membership_expires=date(2019, 12, 30), waiver_expires=date(2019, 12, 30), last_cached=date(2019, 12, 30), ) membership.save() participant = factories.ParticipantFactory.create( membership=membership) # Hasn't updated in 13 months make_last_updated_on(participant, date(2012, 12, 1)) self.assertEqual(cleanup.lapsed_participants().get(), participant)
def test_waiver_current(self): """ Members aren't lapsed if they have a waiver, even with dated profile. """ membership = models.Membership( waiver_expires=date(2020, 1, 1), membership_expires=None, last_cached=date(2019, 12, 1), ) membership.save() participant = factories.ParticipantFactory.create( membership=membership) make_last_updated_on(participant, date(1995, 1, 1)) # Override default of 'now' self.assertEqual(len(cleanup.lapsed_participants()), 0)