def test_generate_text_message(self): text = texthelper.generate_text( {"free_text": "Mrs. Joirie, your " + "medicine is there. " + "Please remember to pay 2 $."}, Template("$free_text"), ) should_text = ( texthelper.SMS_SALUTATION + "Mrs. Joirie, your " + "medicine is there. Please remember to pay 2 $." ) self.assertEquals(text, should_text) self.assertTrue(len(text) <= 160)
def reminder_text(self, contents = False, is_sms = True): """ Return the generated reminder text """ if not contents: contents = {'date': unicode(self.date.date()), 'time': unicode(self.date.time()), 'hospital': self.hospital.name} return texthelper.generate_text(contents, self.template, is_sms)
def get_data_for_sms(self): """ Prepare OutputData for sms. Generate the message for an InfoMessage. Return SMSOutputData for sending. """ data = SMSOutputData() data.data = texthelper.generate_text({'text': self.text}, InfoMessage.template) data.phone_number = self.recipient.phone_number return data
def test_generate_notification_text_cut_off(self): text = texthelper.generate_text( { "text": "Hello my name is james I" + " am 22 years old and i really want to go to " + "bali and make holidays since my last holidays" + " are ages ago and i think a " + "little bit less stress would be fun to have" }, Template("What an interesting text :$text"), ) should_text = ( texthelper.SMS_SALUTATION + "What an interesting text" + " :Hello my name is james I am 22 years old and i " + "really want to go to bali and make " + "holidays since my last holidays are ages ago a" ) self.assertTrue(len(text) <= 160) self.assertEquals(should_text, text)
def test_generate_notification_text_cut_off_special_fields(self): specific_content = { "date": "13.2.98, 3:39", "doctor": "abcdefghijklmnopqrstuvwxyzabcd", "hospital": "hodpielitzkicitziktidiiiiii hospital", "name": "mr joijjliputututututututututu", } text_template = Template( "Dear $name, please remember your " + "notification at the $hospital at $date with doctor $doctor" ) text = texthelper.generate_text(specific_content, text_template) should_text = ( texthelper.SMS_SALUTATION + "Dear mr " + "joijjlipututututututut, please remember your " + "notification at the hodpielitzkicitziktidiiii at " + "13.2.98, 3:39 with doctor abcdefghijklmnopqrstuvwxy" ) self.assertTrue(len(text) <= 160) self.assertEquals(should_text, text)
def test_generate_text_notification(self): text = texthelper.generate_text( { "date": "13.2.98", "time": "3:39", "doctor": "ms daily-binnessy-dayteewart", "hospital": "hodpiel hospital at the " + "lake with the frog and the tree", "name": "mr jameson-bitterall-wertifial", }, Template( "$name, please remember your" + " notification at the $hospital at $date," + " $time with doctor $doctor" ), ) should_text = ( texthelper.SMS_SALUTATION + "mr jameson-bitterall-" + "wertif, please remember your notification at the " + "hodpiel hospital at the lak at 13.2.98, 3:39 with " + "doctor ms daily-binnessy-dayteewar" ) self.assertTrue(len(text) <= 160) self.assertEquals(text, should_text)