Beispiel #1
0
    def test_registration_form_post_valid_data(self):
        """
        Testen dass die View bei einem Post von validen Daten eine
        Weiterleitung zu /registration/success/ zurückgibt.
        """

        post_data = {
            "username": "******",
            "password1": "g3h31M",
            "password2": "g3h31M",
            "email": "*****@*****.**",
            "age": 21,
            "sex": "m",
            "findable": True,
        }
        request = self.factory.post("/registration", post_data)
        response = BlueUserRegistrationFormView.as_view()(request)
        self.assertEqual(response.status_code, 302)
        self.assertTrue(response.has_header("location"))
        self.assertEqual(response.get("location"), "/registration/success")

        user_bill = BlueUser.objects.all()[0]
        self.assertEqual(user_bill.username, post_data["username"])
        self.assertTrue(user_bill.check_password(post_data["password1"]))
        self.assertEqual(user_bill.email, post_data["email"])
        self.assertEqual(user_bill.age, post_data["age"])
        self.assertEqual(user_bill.sex, post_data["sex"])
        self.assertEqual(user_bill.findable, post_data["findable"])
Beispiel #2
0
    def test_registration_form_basic(self):
        """
        Testen dass die View bei einem GET-Aufruf einen 200er Status-Code
        zurückgit und das richtige Template verwendet.
        """

        request = self.factory.get("/registration")
        with self.assertTemplateUsed("registration/registration.html"):
            response = BlueUserRegistrationFormView.as_view()(request)
            self.assertEqual(response.status_code, 200)
            response.render()
Beispiel #3
0
from django.conf.urls import include, url
from django.contrib import admin

from portal.views import BlueUserRegistrationFormView, DashboardView


urlpatterns = [
    url(r'^$', 'portal.views.index'),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^dashboard/$', DashboardView.as_view(), name='dashboard'),
    url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
    url(r'^registration/$', BlueUserRegistrationFormView.as_view(), name='registration'),
    url(r'^registration/success$', 'portal.views.registration_success'),
]