def apply(self): self._adventure, created = self.quest.adventures.get_or_create(user=self.hero) from herobase.models import APPLY_EXPERIENCE # only gives experience when applying the first time if created: self.hero.get_profile().experience += APPLY_EXPERIENCE self.hero.get_profile().save() # reset cancel if cancelled if self.adventure.canceled: self.adventure.canceled = False self.adventure.canceled_time = None self.adventure.save() if self.quest.auto_accept: self.accept() notify.hero_has_joined(self.quest.owner, self.adventure) else: notify.hero_has_applied(self.quest.owner, self.adventure)
def test_mail_subject(self): notify.hero_has_applied(self.applicant, self.adventure) self.assertRegexpMatches( mail.outbox[0].subject, 'beworben', 'subject invalid')
def test_mail_body(self): notify.hero_has_applied(self.applicant, self.adventure) self.assertRegexpMatches( mail.outbox[0].body, 'neue Bewerbung', 'body invalid')
def test_mail_is_sent(self): notify.hero_has_applied(self.applicant, self.adventure) self.assertEqual(len(mail.outbox), 1, 'no message sent')