def test_remove(self): session, session2 = Session(data={'auth_user_id': '123ab'}), Session(data={'auth_user_id': 'ab123'}) session.save() session2.save() assert Session.objects.count() == 2 # sanity check Session.remove(Q('data.auth_user_id', 'eq', '123ab')) assert Session.objects.count() == 1
def remove_sessions_for_user(user): """ Permanently remove all stored sessions for the user from the DB. :param user: User :return: """ from osf.models import Session Session.remove(Q('data.auth_user_id', 'eq', user._id))
def tearDown(self, *args, **kwargs): super(SessionUtilsTestCase, self).tearDown(*args, **kwargs) User.remove() Session.remove()