def _should_renew_for(self, trip, membership_expires) -> bool: membership = models.Membership(membership_expires=membership_expires) should_renew = membership.should_renew_for(trip) # Test some nice helper methods while we're at it if should_renew: # We should only recommend renewal if it's possible if membership_expires: self.assertTrue(membership.in_early_renewal_period) # First-time members *or* renewals should *always* be later than the trip self.assertGreater(membership.expiry_if_paid_today, trip.trip_date) return should_renew
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)
def _should_renew_for(self, trip, membership_expires): membership = models.Membership(membership_expires=membership_expires) return membership.should_renew_for(trip or self.trip)
def test_membership_valid_with_future_expiration(self): membership = models.Membership(membership_expires=date(2019, 10, 13)) self.assertTrue(membership.membership_active)
def test_membership_valid_on_its_last_day(self): membership = models.Membership(membership_expires=date(2018, 11, 19)) self.assertTrue(membership.membership_active)
def test_past_membership_is_not_active(self): membership = models.Membership(membership_expires=date(2018, 11, 18)) self.assertFalse(membership.membership_active)
def test_null_membership_is_not_active(self): membership = models.Membership(membership_expires=None) self.assertFalse(membership.membership_active)