def test_clear_old_registrations(self): first_name = 'old' last_name = 'user' old_user = srusers.user('old') old_user.cname = first_name old_user.sname = last_name old_user.email = '' old_user.save() old_team_leader = User('teacher_coll1') pu = PendingUser('old') pu.teacher_username = old_team_leader.username pu.college = 'college-1' pu.team = 'team-ABC' pu.email = '*****@*****.**' pu.verify_code = 'bibble-old' pu.save() self._make_old('registrations', 'old') pu = PendingUser('abc') pu.teacher_username = '******' pu.college = 'new-college-1' pu.team = 'team-NEW' pu.email = '*****@*****.**' pu.verify_code = 'bibble' pu.save() helpers.clear_old_registrations() pu = PendingUser('old') assert not pu.in_db pu = PendingUser('abc') assert pu.in_db ps = last_email() toaddr = ps.toaddr team_lead_email = old_team_leader.email assert toaddr == team_lead_email vars = ps.template_vars team_lead_first = old_team_leader.first_name assert team_lead_first == vars['name'] assert first_name == vars['pu_first_name'] assert last_name == vars['pu_last_name'] template = ps.template_name assert template == 'registration_expired'
#!/usr/bin/env python3 import os import sys nemesis_root = os.path.dirname(os.path.abspath(__file__)) + "/../" sys.path.insert(0, nemesis_root) import config import helpers if __name__ == "__main__": config.configure_logging() helpers.clear_old_emails() helpers.clear_old_password_resets() helpers.clear_old_registrations() #helpers.send_emails()
#!/usr/bin/env python import os import sys nemesis_root = os.path.dirname(os.path.abspath(__file__)) + "/../" sys.path.insert(0, nemesis_root) import config import helpers if __name__ == "__main__": config.configure_logging() helpers.clear_old_emails() helpers.clear_old_password_resets() helpers.clear_old_registrations() #helpers.send_emails()
def test_clear_old_registrations(self): first_name = 'old' last_name = 'user' old_user = srusers.user('old') old_user.cname = first_name old_user.sname = last_name old_user.email = '' # match what libnemesis does when registering users old_user.save() old_team_leader = User('teacher_coll1') pu = PendingUser('old') email = '*****@*****.**' pu.teacher_username = old_team_leader.username pu.college = 'college-1' pu.team = 'team-ABC' pu.email = email pu.verify_code = 'bibble-old' pu.save() self._make_old('registrations', 'old') pu = PendingUser('abc') pu.teacher_username = '******' pu.college = 'new-college-1' pu.team = 'team-NEW' pu.email = '*****@*****.**' pu.verify_code = 'bibble' pu.save() helpers.clear_old_registrations() pu = PendingUser('old') assert not pu.in_db pu = PendingUser('abc') assert pu.in_db emails = last_n_emails(2) # Check we emailed the competitor ps = emails[0] toaddr = ps.toaddr assert email == toaddr vars = ps.template_vars assert first_name == vars['name'] template = ps.template_name assert template == 'registration_expired' assert_load_template(template, vars) # Check we emailed the team leader ps = emails[1] toaddr = ps.toaddr team_lead_email = old_team_leader.email assert toaddr == team_lead_email vars = ps.template_vars team_lead_first = old_team_leader.first_name assert team_lead_first == vars['name'] assert first_name == vars['pu_first_name'] assert last_name == vars['pu_last_name'] template = ps.template_name assert template == 'registration_expired_team_leader' assert_load_template(template, vars)