Esempio n. 1
0
 def test_filtering_adviser_users(self):
     """
     Ensure we can filter AdviserUsers
     """
     adviser_users = AdviserUser.filter()
     self.assertEqual(adviser_users.count(),
                      AdviserUser.objects.filter().count())
Esempio n. 2
0
 def test_updating_adviser_user_info(self):
     """
     Ensure we can update fields of AdviserUser
     """
     updated_user = AdviserUser.update(10, avatar="new_avatar.jpg")
     self.assertEqual(updated_user.avatar,
                      AdviserUser.objects.get(id=10).avatar)
Esempio n. 3
0
 def test_creating_adviser_user(self):
     """
     Ensure we can create AdviserUser
     """
     adviser_user = AdviserUser.create(id=8, id_company=Company.objects.get(id=1),
                                       user=User.objects.get(id=30), avatar="Test")
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=8))
Esempio n. 4
0
 def test_filtering_adviser_users(self):
     """
     Ensure we can filter AdviserUsers
     """
     adviser_users = AdviserUser.filter()
     self.assertEqual(adviser_users.count(),
                      AdviserUser.objects.filter().count())
Esempio n. 5
0
 def test_creating_adviser_user_on_invitation_and_form(self):
     """
     Ensure we can crate AdviserUser using AdviserInvitation and Form
     """
     test_user = {"first_name": "Test", "last_name": "Test", "password": "******",
                  "confirm_password": "******"}
     registration_form = UserRegistrationForm(test_user)
     adviser_user = AdviserUser.create_user(registration_form, AdviserInvitations.objects.get(id=1))
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=adviser_user.id))
Esempio n. 6
0
 def test_creating_adviser_user(self):
     """
     Ensure we can create AdviserUser
     """
     adviser_user = AdviserUser.create(id=8,
                                       id_company=Company.objects.get(id=1),
                                       user=User.objects.get(id=30),
                                       avatar="Test")
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=8))
Esempio n. 7
0
    def post(self, request):
        """
        Handling GET method
        :param request: Request to View
        :return: HttpResponse with code 201 if user is created or
        HttpResponseBadRequest if request contain incorrect data
        """
        verification_code = request.GET.get("code", "")

        invitation = AdviserInvitations.get_invitation(verification_code)

        user_registration_form = UserRegistrationForm(json.loads(request.body))

        if not user_registration_form.is_valid():
            return HttpResponseBadRequest("Invalid input data. Please edit and try again.")

        AdviserUser.create_user(user_registration_form, invitation)

        invitation.close_invitation()

        return HttpResponse(status=201)
Esempio n. 8
0
    def post(self, request):
        """
        Handling GET method
        :param request: Request to View
        :return: HttpResponse with code 201 if user is created or
        HttpResponseBadRequest if request contain incorrect data
        """
        verification_code = request.GET.get("code", "")

        invitation = AdviserInvitations.get_invitation(verification_code)

        user_registration_form = UserRegistrationForm(json.loads(request.body))

        if not user_registration_form.is_valid():
            return HttpResponseBadRequest(
                "Invalid input data. Please edit and try again.")

        AdviserUser.create_user(user_registration_form, invitation)

        invitation.close_invitation()

        return HttpResponse(status=201)
Esempio n. 9
0
 def test_creating_adviser_user_on_invitation_and_form(self):
     """
     Ensure we can crate AdviserUser using AdviserInvitation and Form
     """
     test_user = {
         "first_name": "Test",
         "last_name": "Test",
         "password": "******",
         "confirm_password": "******"
     }
     registration_form = UserRegistrationForm(test_user)
     adviser_user = AdviserUser.create_user(
         registration_form, AdviserInvitations.objects.get(id=1))
     self.assertEqual(adviser_user,
                      AdviserUser.objects.get(id=adviser_user.id))
Esempio n. 10
0
 def test_updating_adviser_user_info(self):
     """
     Ensure we can update fields of AdviserUser
     """
     updated_user = AdviserUser.update(10, avatar="new_avatar.jpg")
     self.assertEqual(updated_user.avatar, AdviserUser.objects.get(id=10).avatar)
Esempio n. 11
0
 def test_getting_adviser_user_by_id(self):
     """
     Ensure we can get AdviserUsers by id
     """
     adviser_user = AdviserUser.get(10)
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=10))
Esempio n. 12
0
 def test_getting_adviser_user_by_id(self):
     """
     Ensure we can get AdviserUsers by id
     """
     adviser_user = AdviserUser.get(10)
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=10))