def test_skip_valid_subscription(self, mocked_date, User): mocked_date.today.return_value = date(2013, 12, 30) user = self._make_user(valid_to=date(2013, 12, 31)) User.get_all.return_value = [ user, ] expire_subscriptions() self.assertEqual(user.disable.call_count, 0)
def test_skip_valid_addon_subscription(self, mocked_date, User): mocked_date.today.return_value = date(2013, 12, 30) user = self._make_user(valid_to=date(2013, 12, 31)) user.properties = [ UserProperty(key='addon_1_valid_to', value='2014-12-31'), ] User.get_all.return_value = [ user, ] expire_subscriptions() self.assertEqual(user.groups.remove.call_count, 0)
def test_disable_expired_member(self, mocked_date): mocked_date.today.return_value = date(2013, 12, 30) user = User.by_email('*****@*****.**') user.valid_to = date(2013, 12, 29) transaction.commit() expire_subscriptions() user = User.by_email('*****@*****.**') self.assertFalse(user.enabled) self.assertEqual(len(user.audit_log_entries), 1) self.assertEqual(user.audit_log_entries[0].event_type.name, u'UserDisabled') self.assertEqual( user.audit_log_entries[0].comment, u'Disabled user [email protected] (1) because its ' u'valid_to (2013-12-29) has expired.', )
def test_disable_expired_addon(self, mocked_date): mocked_date.today.return_value = date(2013, 12, 30) user = User.by_email('*****@*****.**') user.valid_to = date(2013, 12, 31) user.set_property('addon_1_valid_to', date(2013, 12, 29)) user.groups.append(Group(name='foo', product_id=1)) transaction.commit() expire_subscriptions() user = User.by_email('*****@*****.**') self.assertTrue(user.enabled) self.assertEqual([g.name for g in user.groups], ['admins', 'enabled']) self.assertEqual(len(user.audit_log_entries), 1) self.assertEqual(user.audit_log_entries[0].event_type.name, u'UserDisabled') self.assertEqual( user.audit_log_entries[0].comment, u'Addon "foo" disabled for user [email protected] (1) because its ' u'valid_to (2013-12-29) has expired.', )