Ejemplo n.º 1
0
 def test_is_token_valid(self):
     token = make_token()
     invite = Invitation.objects.create(user=self.creator, email="*****@*****.**",
         token=token, content_object=self.event)
     self.failUnless(self.event.is_token_valid(token))
     new_event = Event.objects.create(creator=self.creator,
         location=self.ashaway, when=datetime.date(2050, 9, 9), start=datetime.time(9,0),
         duration=90, details="test", default_survey=self.survey)
     self.failUnless(not new_event.is_token_valid(token))
Ejemplo n.º 2
0
 def test_valid_token(self):
     self.event.is_private = True
     self.event.save()
     token = make_token()
     invite = Invitation.objects.create(user=self.user, email="*****@*****.**",
         token=token, content_object=self.event)
     self.client.login(username="******", password="******")
     response = self.client.get(reverse("event-invite", args=[self.event.id, invite.token]), follow=True)
     self.failUnlessEqual(response.template[0].name, "events/detail.html")
     event = response.context["event"]
     self.failUnlessEqual(event.where, "123 Garden Street")
     self.failUnlessEqual(event.location.name, "Ashaway")
     self.failUnlessEqual(event.location.st, "RI")
     self.failUnlessEqual(event.location.zipcode, "02804")
     self.failUnlessEqual(event.when, datetime.date(2050, 8, 14))
     self.failUnlessEqual(event.start, datetime.time(6, 0))
     self.failUnlessEqual(event.duration, 90)
     self.failUnlessEqual(event.details, "You can park on the street.  My apartment is on the second floor.")
     self.failUnlessEqual(event.is_private, True)
Ejemplo n.º 3
0
 def test_make_token(self):
     match = True if re.match(r'[a-f0-9]{15}', make_token()) else False
     self.failUnlessEqual(match, True)
Ejemplo n.º 4
0
 def setUp(self):
     self.client = Client()
     self.user = User.objects.create_user(username="******", email="*****@*****.**", password="******")
     self.post = Post.objects.create(content="test post")
     self.post_content_type = ContentType.objects.get(app_label="invite", model="post")
     self.invite = Invitation.objects.create(user=self.user, email="*****@*****.**", token=make_token())
     self.new_user = User.objects.create_user(username="******", email="*****@*****.**", password="******")