Exemple #1
0
    def test_receive_sms(self):
        # Test sending a message
        signup_data = self.APPLICATION_DATA.copy()
        signup_data['contact_method'] = 'Text'
        signup_data['mobile'] = '123-456-7890'
        signup_data['study_group'] = StudyGroup.objects.all()[0]
        signup = Application(**signup_data)
        signup.accepted_at = timezone.now()
        signup.save()

        c = Client()
        url = '/en/receive_sms/'
        sms_data = {
            u'Body': 'The first study group for GED® Prep Math will meet next Thursday, May 7th, from 6:00 pm-7:45 pm at Edgewater on the 2nd floor. Feel free to bring a study buddy!',
            u'From': '+11234567890'
        }
        resp = c.post(url, sms_data)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue(mail.outbox[0].subject.find('123-456-7890') > 0)
        self.assertTrue(mail.outbox[0].subject.find('Test User') > 0)
Exemple #2
0
 def test_send_sms(self, send_message):
     c = Client()
     c.login(username='******', password='******')
     signup_data = self.APPLICATION_DATA.copy()
     signup_data['contact_method'] = Application.TEXT
     signup_data['mobile'] = '123-456-7890'
     signup_data['study_group'] = StudyGroup.objects.all()[0]
     signup = Application(**signup_data)
     signup.accepted_at = timezone.now()
     signup.save()
     url = '/en/studygroup/{0}/message/compose/'.format(signup.study_group_id)
     mail_data = {
         'study_group': signup.study_group_id,
         'email_subject': 'test', 
         'email_body': 'Email body', 
         'sms_body': 'Sms body'
     }
     resp = c.post(url, mail_data)
     self.assertRedirects(resp, '/en/facilitator/')
     self.assertEqual(len(mail.outbox), 0)
     self.assertTrue(send_message.called)
Exemple #3
0
    def test_send_email(self, send_message):
        # Test sending a message
        c = Client()
        c.login(username='******', password='******')
        signup_data = self.APPLICATION_DATA.copy()
        signup_data['study_group'] = StudyGroup.objects.all()[0]
        signup = Application(**signup_data)
        signup.accepted_at = timezone.now()
        signup.save()
        url = '/en/studygroup/{0}/message/compose/'.format(signup.study_group_id)
        email_body = u'Hi there!\n\nThe first study group for GED® Prep Math will meet this Thursday, May 7th, from 6:00 pm - 7:45 pm at Edgewater on the 2nd floor. Feel free to bring a study buddy!\nFor any questions you can contact Emily at [email protected].\n\nSee you soon'
        mail_data = {
            u'study_group': signup.study_group_id,
            u'email_subject': u'GED® Prep Math study group meeting Thursday 7 May 6:00 PM at Edgewater', 
            u'email_body': email_body, 
            u'sms_body': 'The first study group for GED® Prep Math will meet next Thursday, May 7th, from 6:00 pm-7:45 pm at Edgewater on the 2nd floor. Feel free to bring a study buddy!'
        }
        resp = c.post(url, mail_data)
        self.assertRedirects(resp, '/en/facilitator/')

        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, mail_data['email_subject'])
        self.assertFalse(send_message.called)