def prepare(self): self.user = create_user("tester", "xxx", "*****@*****.**") self.zapisnik = Zapisnik(site=self.user.get_profile().site, owner=self.user, visitor=self.user) self.article = self.zapisnik.create_article_draft( annotation = "annotation", title = "title", content = """This is ""article"" content""", tags = "tagity tag" )
def setUp(self): super(TestAgenda, self).setUp() self.user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.holger = create_user(u"Holger", "xxx", "*****@*****.**") self.now = datetime.now() self.event = create_event( title = u"PragoCon", start = self.now, end = self.now + timedelta(hours=1), description = u''' = Cool event = Sluníčkový event s unicodem. ""Frikulínskej"", as in """角色扮演游戏""". ''', is_public = True, facebook_publish = False, author = self.user ) self.agenda_one = create_event( title = u"Úvod do Poezie", start = self.now, end = self.now + timedelta(hours=1), description = u''' = Úvod do poezie = S Olgou. Bude tam hodně znaků. ''', is_public = True, facebook_publish = False, author = self.holger, parent = self.event, place = u'Místnost 1' )
def setUp(self): super(TestArticleManipulation, self).setUp() self.user = create_user("tester", "xxx", "*****@*****.**") self.zapisnik = Zapisnik(site=self.user.get_profile().site, owner=self.user, visitor=self.user)
def inviteform(request, template='registration/inviteform.html'): message = '' if request.POST.get("traditional_registration", None): registration_form = RegistrationForm(request.POST) if registration_form.is_valid(): user = create_user( username = registration_form.cleaned_data['username'], password = registration_form.cleaned_data['password1'], email = registration_form.cleaned_data['email'] ) return HttpResponseRedirect(reverse('service:profile', kwargs={ "user_slug" : user.get_profile().slug })) else: registration_form = RegistrationForm() if not getattr(settings, "FACEBOOK_APPLICATION_ID", None) or not getattr(settings, "FACEBOOK_APPLICATION_SECRET", None): warnings.warn("FACEBOOK_APPLICATION_ID or FACEBOOK_APPLICATION_SECRET not given, not handling FB authentication") if request.POST.get("facebook_registration", None): fb_form = FacebookForm(request.POST) fb_form.visible = True if fb_form.is_valid(): if not getattr(settings, "FACEBOOK_APPLICATION_ID", None) or not getattr(settings, "FACEBOOK_APPLICATION_SECRET", None): message = u"Aplikace bohužel nemá k dispozici nastavení potřebná na používání s Facebookem :-/" else: fb_info = facebook.get_user_from_cookie(request.COOKIES, settings.FACEBOOK_APPLICATION_ID, settings.FACEBOOK_APPLICATION_SECRET) if not fb_info: message = u"Nepodařilo se získat informace z Facebooku. Má problémy? Nebo došlo k chybě při přenosu informací? Zkuste to znovu." else: graph = facebook.GraphAPI(fb_info["access_token"]) profile = graph.get_object("me") # friends = graph.get_connections("me", "friends") if 'email' not in profile: message = u"Neposkytl jsi mi e-mail, ale já ho skutečně potřebuji pro fungování. Prosím odhlaš se z Facebook a tentokrát mi ho poskytni :o)" else: try: InvitedEmail.objects.get(email=profile['email']) except InvitedEmail.DoesNotExist, err: message = u"Na tento e-mail není dostupná žádná pozvánka. Omlouváme se - poprostě někoho registrovaného, nebo se přijďte podívat později!" else: # finally, we can create profile user = create_user( username = fb_form.cleaned_data['rpgp_username'], password = '', email = profile['email'] ) account = FacebookAccount( user = user ) for fb_key, model_key in ( ("uid", "facebook_uid"), ("access_token", "access_token"), ("secret", "secret"), ("sig", "signature"), ("session_key", "session_key"), ): setattr(account, model_key, fb_info[fb_key]) account.expires = datetime.utcfromtimestamp(float(fb_info['expires'])) account.set_json_data(profile) account.save() return HttpResponseRedirect(reverse('service:profile', kwargs={ "user_slug" : user.get_profile().slug }))
def setUp(self): super(TestEventsCreation, self).setUp() self.now = datetime.now() self.user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**")
def test_available_to_created_and_forced(self): create_user("tester", "xxx", "*****@*****.**") self.transaction.commit() res = urlopen(get_live_server_path()) self.assert_equals(200, res.code)
def setUp(self): super(TestBasicLayout, self).setUp() create_user(u"Testeřík", "xxx", "*****@*****.**") self.transaction.commit()
def test_andros_properly_slugified(self): user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.assert_equals('andrej-tokarcik', user.get_profile().slug)
def test_mandatory_categories_created(self): user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.assert_equals(3, len(Category.objects.filter(site=user.get_profile().site)))
def test_root_category_created(self): user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.assert_equals(1, len(Category.objects.filter(site=user.get_profile().site, tree_path="")))
def test_registering_same_slug_error(self): create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.assert_raises(ValueError, create_user, u" Andrej-Tokarcik ", "xerox", "*****@*****.**")
def test_registering_same_email_causes_error(self): create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**") self.assert_raises(ValueError, create_user, u"Neumětel", "xerox", "*****@*****.**")