Exemple #1
0
 def test_edit_register_user_form_invalid(self):
     request = self.factory.post("/newuser/", self.data)
     request.user = AnonymousUser()
     request = add_middleware_to_request(request, SessionMiddleware)
     request.session.save()
     response = RegisterUser.as_view()(request)
     new_user = User.objects.get(email="*****@*****.**")
     new_data = {"id": new_user.id,
                 "username": "******",
                 "email": "*****@*****.**"}
     request = self.factory.post("/newuser/", new_data)
     response = RegisterUser.as_view()(request)
     context = response.context_data
     self.assertFalse(context['form'].is_valid())
Exemple #2
0
    def test_register_user_form(self):
        request = self.factory.get("/newuser/")
        request.user = AnonymousUser()

        request = add_middleware_to_request(request, SessionMiddleware)
        request.session.save()

        response = RegisterUser.as_view()(request)
        self.assertContains(response, "Cadastre-se grátis")
Exemple #3
0
 def test_edit_register_user_form_valid(self):
     request = self.factory.post("/newuser/", self.data)
     request.user = AnonymousUser()
     request = add_middleware_to_request(request, SessionMiddleware)
     request.session.save()
     response = RegisterUser.as_view()(request)
     new_user = User.objects.get(email="*****@*****.**")
     new_data = {"id": new_user.id,
                 "username": "******",
                 "email": "*****@*****.**",
                 "first_name": "John",
                 "last_name": "Doe",
                 "password": "******",
                 "organization": "org_teste"}
     request = self.factory.post("/newuser/", new_data)
     response = RegisterUser.as_view()(request)
     user_edited = User.objects.get(email="*****@*****.**")
     self.assertEqual(new_user.first_name, "John")
Exemple #4
0
    def test_register_user_form(self):
        request = self.factory.get("/newuser/")
        request.user = AnonymousUser()

        request = add_middleware_to_request(request, SessionMiddleware)
        request.session.save()

        response = RegisterUser.as_view()(request)
        self.assertContains(response, "Cadastro de Usuário")
Exemple #5
0
    def test_register_user_form_valid(self):
        request = self.factory.post("/newuser/", self.data)
        request.user = AnonymousUser()

        request = add_middleware_to_request(request, SessionMiddleware)
        request.session.save()

        response = RegisterUser.as_view()(request)
        self.assertEqual(response.status_code, 302)
        new_user = User.objects.get(email="*****@*****.**")
        self.assertEqual(new_user.first_name, "John")
Exemple #6
0
    def test_register_user_form_valid(self):
        request = self.factory.post("/newuser/", self.data)
        request.user = AnonymousUser()

        request = add_middleware_to_request(request, SessionMiddleware)
        request.session.save()

        response = RegisterUser.as_view()(request)
        self.assertEqual(response.status_code, 302)
        new_user = User.objects.get(email="*****@*****.**")
        self.assertEqual(new_user.first_name, "John")
Exemple #7
0
    def create_user(self, username="******", email="*****@*****.**", first_name="John", last_name="Doe", password="******", organization="org_teste"):
        self.data['username'] = username
        self.data['email'] = email
        self.data['first_name'] = first_name
        self.data['last_name'] = last_name
        self.data['password'] = password
        self.data['organization'] = organization

        request = self.factory.post("/newuser/", self.data)
        request.user = AnonymousUser()

        request = add_middleware_to_request(request, SessionMiddleware)
        request.session.save()

        response = RegisterUser.as_view()(request)
        return User.objects.get(email=email)