def test_sends_copies_to_each_recipient_for_CLUE_or_HINT(self): phones = ['+1234', '+555', '+678'] self.group.users = phones messages = [Clue(text='Hey there!')] response = twiml_response(self.user, self.group, CLUE, messages) for p in phones: self.assertIn(p, response) response = twiml_response(self.user, self.group, HINT, messages) for p in phones: self.assertIn(p, response)
def test_does_not_send_copies_to_each_recipient_for_other_response_types(self): phones = ['+1234', '+555', '+678'] self.group.users = phones other_phones = set(phones) - set(['+1234']) messages = [Clue(text='Hey there!')] response = twiml_response(self.user, self.group, INFO, messages) for p in other_phones: self.assertNotIn(p, response) response = twiml_response(self.user, self.group, JOINED, messages) for p in other_phones: self.assertNotIn(p, response)
def test_does_not_include_sender_if_empty(self): messages = [Clue(text='my_clue', sender='')] response = twiml_response(self.user, None, ANSWER, messages) self.assertNotIn('from', response)
def test_sends_from_specific_number_if_specified(self): messages = [Clue(text='my_clue', sender='+1112223333')] response = twiml_response(self.user, None, ANSWER, messages) self.assertIn('from="+1112223333"', response)
def test_extracts_text_from_clues(self): messages = [Clue(text='my_clue'), Clue(text='my_other_clue')] response = twiml_response(self.user, None, START_STORY, messages) self.assertIn('my_clue', response) self.assertIn('my_other_clue', response)
def test_does_not_send_media_more_than_once(self): messages = [Clue(text='my_clue', media_url='picture.com/my.png'), Clue(text='my_other_clue')] response = twiml_response(self.user, None, START_STORY, messages) count = response.count('picture.com/my.png') self.assertEqual(1, count)
def test_sends_media_urls_from_clues(self): messages = [Clue(text='my_clue', media_url='picture.com/my.png'), Clue(text='my_other_clue', media_url='second.com/my.jpg')] response = twiml_response(self.user, None, START_STORY, messages) self.assertIn('<Media>picture.com/my.png</Media>', response) self.assertIn('<Media>second.com/my.jpg</Media>', response)
def test_includes_messages_in_response(self): messages = [Clue(text='Hey there!')] response = twiml_response(self.user, None, START_STORY, messages) for m in messages: self.assertIn(m.text, response)