def test_database(self): db = Database() db.create_and_empty_tables() db.log(1234, 'test', 'content') logs = db.fetch_logs() self.assertEqual(logs[0]['event'],'test') db.new_participant(123456789, 987654321, '2014-05-04', '2014-06-05') db.update_participant(123456789,"twilio", 1111111111) participants = db.load_participants() self.assertEqual(participants[0][0],123456789) db.log_email('test@test','$0.36') emails = db.fetch_email() self.assertEqual(emails[0]['email'],'test@test') db.create_and_empty_tables()
def new_participant(): if request.method == 'GET': return render_template('new-participant.html') else: # password = economics if request.form['pwd'] == config_vars.interface_pwd: # create new participant lab_day = (valid_time(request.form['lab_day']) - datetime.now()).days money_day = (valid_time(request.form['money_day']) - datetime.now()).days phone_number = valid_number(request.form['phone']) twilio_number = valid_number(request.form['twilio']) if lab_day and money_day and phone_number and twilio_number: participants[phone_number] = Participant(phone_number,twilio_number,0,datetime.now(),lab_day,money_day) db = Database() db.new_participant(phone_number,twilio_number,lab_day,money_day) participants[phone_number].send_verification() return render_template('new-participant.html') return 'invalid input'